[shotwell] Tumblr,Flicker: Fix authorization



commit f8849b8dfa51c3a6718dbf72261f5002798b8f8f
Author: Jens Georg <mail jensge org>
Date:   Thu Nov 16 21:43:11 2017 +0100

    Tumblr,Flicker: Fix authorization

 plugins/common/RESTSupport.vala                   |   15 +++++++++++----
 plugins/shotwell-publishing/FlickrPublishing.vala |    3 +--
 plugins/shotwell-publishing/TumblrPublishing.vala |    2 +-
 3 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 5c02992..6568bef 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -885,8 +885,8 @@ namespace OAuth1 {
         private string? consumer_key = null;
         private string? consumer_secret = null;
 
-        public Session() {
-            base();
+        public Session(string? endpoint_uri = null) {
+            base(endpoint_uri);
         }
 
         public override bool is_authenticated() {
@@ -1000,6 +1000,10 @@ namespace OAuth1 {
             return access_phase_token;
         }
 
+        public bool has_access_phase_token() {
+            return access_phase_token != null;
+        }
+
         public string get_access_phase_token_secret() {
             assert(access_phase_token_secret != null);
             return access_phase_token_secret;
@@ -1032,6 +1036,9 @@ namespace OAuth1 {
             add_argument("oauth_version", "1.0");
             add_argument("oauth_timestamp", session.get_oauth_timestamp());
             add_argument("oauth_consumer_key", session.get_consumer_key());
+            if (session.has_access_phase_token()) {
+                add_argument("oauth_token", session.get_access_phase_token());
+            }
         }
 
 
@@ -1043,7 +1050,7 @@ namespace OAuth1 {
     }
 
     public class UploadTransaction : Publishing.RESTSupport.UploadTransaction {
-        protected Publishing.RESTSupport.OAuth1.Session session;
+        protected unowned Publishing.RESTSupport.OAuth1.Session session;
         private Publishing.RESTSupport.Argument[] auth_header_fields;
 
         public UploadTransaction(Publishing.RESTSupport.OAuth1.Session session,
@@ -1052,11 +1059,11 @@ namespace OAuth1 {
             base.with_endpoint_url(session, publishable, endpoint_uri);
 
             this.auth_header_fields = new Publishing.RESTSupport.Argument[0];
+            this.session = session;
 
             add_authorization_header_field("oauth_nonce", session.get_oauth_nonce());
             add_authorization_header_field("oauth_signature_method", "HMAC-SHA1");
             add_authorization_header_field("oauth_version", "1.0");
-            add_authorization_header_field("oauth_callback", "oob");
             add_authorization_header_field("oauth_timestamp", session.get_oauth_timestamp());
             add_authorization_header_field("oauth_consumer_key", session.get_consumer_key());
             add_authorization_header_field("oauth_token", session.get_access_phase_token());
diff --git a/plugins/shotwell-publishing/FlickrPublishing.vala 
b/plugins/shotwell-publishing/FlickrPublishing.vala
index a31c809..5a80284 100644
--- a/plugins/shotwell-publishing/FlickrPublishing.vala
+++ b/plugins/shotwell-publishing/FlickrPublishing.vala
@@ -59,7 +59,6 @@ internal const string SERVICE_NAME = "Flickr";
 internal const string ENDPOINT_URL = "https://api.flickr.com/services/rest";;
 internal const int ORIGINAL_SIZE = -1;
 internal const string EXPIRED_SESSION_ERROR_CODE = "98";
-internal const string ENCODE_RFC_3986_EXTRA = "!*'();:@&=+$,/?%#[] \\";
 
 internal enum UserKind {
     PRO,
@@ -107,7 +106,7 @@ public class FlickrPublisher : Spit.Publishing.Publisher, GLib.Object {
         debug("FlickrPublisher instantiated.");
         this.service = service;
         this.host = host;
-        this.session = new Publishing.RESTSupport.OAuth1.Session();
+        this.session = new Publishing.RESTSupport.OAuth1.Session(ENDPOINT_URL);
         this.parameters = new PublishingParameters();
         this.authenticator = Publishing.Authenticator.Factory.get_instance().create("flickr", host);
 
diff --git a/plugins/shotwell-publishing/TumblrPublishing.vala 
b/plugins/shotwell-publishing/TumblrPublishing.vala
index ce00a25..1da9c61 100644
--- a/plugins/shotwell-publishing/TumblrPublishing.vala
+++ b/plugins/shotwell-publishing/TumblrPublishing.vala
@@ -123,7 +123,7 @@ namespace Publishing.Tumblr {
             debug("TumblrPublisher instantiated.");
             this.service = service;
             this.host = host;
-            this.session = new Publishing.RESTSupport.OAuth1.Session();
+            this.session = new Publishing.RESTSupport.OAuth1.Session(ENDPOINT_URL);
             this.sizes = this.create_sizes();
             this.blogs = this.create_blogs();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]