diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:35:52 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:35:52 +0200 |
commit | b86540b743f1a87a163ffb811c8fe22a01fefa38 (patch) | |
tree | b47cb3bb83c2377234226fb3987ab3320a987dd9 /plugins/authenticator/shotwell/TumblrAuthenticator.vala | |
parent | ac6e0b731b9f0b2efd392e3309a5c07e2a66adad (diff) | |
parent | e905d8e16eec152d19797937f13ba3cf4b8f8aca (diff) |
Merge branch 'release/debian/0.32.1-1'debian/0.32.1-1
Diffstat (limited to 'plugins/authenticator/shotwell/TumblrAuthenticator.vala')
-rw-r--r-- | plugins/authenticator/shotwell/TumblrAuthenticator.vala | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/plugins/authenticator/shotwell/TumblrAuthenticator.vala b/plugins/authenticator/shotwell/TumblrAuthenticator.vala index 8907a80..e77814b 100644 --- a/plugins/authenticator/shotwell/TumblrAuthenticator.vala +++ b/plugins/authenticator/shotwell/TumblrAuthenticator.vala @@ -119,7 +119,7 @@ namespace Publishing.Authenticator.Shotwell.Tumblr { public AccessTokenFetchTransaction(Publishing.RESTSupport.OAuth1.Session session, string username, string password) { base.with_uri(session, "https://www.tumblr.com/oauth/access_token", Publishing.RESTSupport.HttpMethod.POST); - add_argument("x_auth_username", Soup.URI.encode(username, ENCODE_RFC_3986_EXTRA)); + add_argument("x_auth_username", username); add_argument("x_auth_password", password); add_argument("x_auth_mode", "client_auth"); } @@ -127,7 +127,7 @@ namespace Publishing.Authenticator.Shotwell.Tumblr { internal class Tumblr : Publishing.Authenticator.Shotwell.OAuth1.Authenticator { public Tumblr(Spit.Publishing.PluginHost host) { - base(API_KEY, API_SECRET, host); + base("Tumblr", API_KEY, API_SECRET, host); } public override void authenticate() { @@ -190,7 +190,7 @@ namespace Publishing.Authenticator.Shotwell.Tumblr { private void on_authentication_pane_login_clicked( string username, string password ) { debug("EVENT: on_authentication_pane_login_clicked"); - do_network_login(username, password); + do_network_login.begin(username, password); } /** @@ -201,41 +201,24 @@ namespace Publishing.Authenticator.Shotwell.Tumblr { * @param username the name of the Tumblr user used to login * @param password the password of the Tumblr user used to login */ - private void do_network_login(string username, string password) { + private async void do_network_login(string username, string password) { debug("ACTION: logging in"); host.set_service_locked(true); host.install_login_wait_pane(); AccessTokenFetchTransaction txn = new AccessTokenFetchTransaction(session,username,password); - txn.completed.connect(on_auth_request_txn_completed); - txn.network_error.connect(on_auth_request_txn_error); - try { - txn.execute(); - } catch (Spit.Publishing.PublishingError err) { + yield txn.execute_async(); + debug("EVENT: OAuth authentication request transaction completed; response = '%s'", + txn.get_response()); + + do_parse_token_info_from_auth_request(txn.get_response()); + } catch (Error err) { + debug("EVENT: OAuth authentication request transaction caused a network error"); host.post_error(err); } } - private void on_auth_request_txn_completed(Publishing.RESTSupport.Transaction txn) { - txn.completed.disconnect(on_auth_request_txn_completed); - txn.network_error.disconnect(on_auth_request_txn_error); - - debug("EVENT: OAuth authentication request transaction completed; response = '%s'", - txn.get_response()); - - do_parse_token_info_from_auth_request(txn.get_response()); - } - - private void on_auth_request_txn_error(Publishing.RESTSupport.Transaction txn, - Spit.Publishing.PublishingError err) { - txn.completed.disconnect(on_auth_request_txn_completed); - txn.network_error.disconnect(on_auth_request_txn_error); - - debug("EVENT: OAuth authentication request transaction caused a network error"); - host.post_error(err); - } - private void do_parse_token_info_from_auth_request(string response) { debug("ACTION: extracting access phase credentials from '%s'", response); @@ -255,7 +238,7 @@ namespace Publishing.Authenticator.Shotwell.Tumblr { "least one of these is absent")); this.authentication_failed(); } else { - session.set_access_phase_credentials(token, token_secret, ""); + session.set_access_phase_credentials(token, token_secret, "unused"); } } } |