[shotwell/wip/flickr-description: 3/5] Fix Tumblr support after the OAuth fix for Flickr
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/flickr-description: 3/5] Fix Tumblr support after the OAuth fix for Flickr
- Date: Thu, 12 Mar 2020 19:43:39 +0000 (UTC)
commit df6f067f6a699f6c4daf5441b5d94542083bec88
Author: Jens Georg <mail jensge org>
Date: Thu Mar 12 17:10:00 2020 +0100
Fix Tumblr support after the OAuth fix for Flickr
Also fixes #221
.../shotwell/TumblrAuthenticator.vala | 2 +-
plugins/common/OAuth1Support.vala | 2 +-
plugins/common/RESTSupport.vala | 10 ++++++++-
plugins/shotwell-publishing/TumblrPublishing.vala | 26 +++-------------------
4 files changed, 14 insertions(+), 26 deletions(-)
---
diff --git a/plugins/authenticator/shotwell/TumblrAuthenticator.vala
b/plugins/authenticator/shotwell/TumblrAuthenticator.vala
index 35fdce98..baeaa48e 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");
}
diff --git a/plugins/common/OAuth1Support.vala b/plugins/common/OAuth1Support.vala
index 009bc8a7..e94f5fa3 100644
--- a/plugins/common/OAuth1Support.vala
+++ b/plugins/common/OAuth1Support.vala
@@ -62,7 +62,7 @@ namespace Publishing.RESTSupport.OAuth1 {
Publishing.RESTSupport.Argument[] sorted_args =
Publishing.RESTSupport.Argument.sort(base_string_arguments);
- var arguments_string = Argument.serialize_list(sorted_args);
+ var arguments_string = Argument.serialize_for_sbs(sorted_args);
string? signing_key = null;
if (access_phase_token_secret != null) {
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 6aa2b7ab..cb050189 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -126,7 +126,15 @@ public class Argument {
this.value = value;
}
- public static string serialize_list(Argument[] args, bool encode = true, bool escape = false, string?
separator = "&") {
+ public static string serialize_for_sbs(Argument[] args) {
+ return Argument.serialize_list(args, true, false, "&");
+ }
+
+ public static string serialize_for_authorization_header(Argument[] args) {
+ return Argument.serialize_list(args, false, true, ", ");
+ }
+
+ public static string serialize_list(Argument[] args, bool encode, bool escape, string? separator) {
var builder = new StringBuilder("");
foreach (var arg in args) {
diff --git a/plugins/shotwell-publishing/TumblrPublishing.vala
b/plugins/shotwell-publishing/TumblrPublishing.vala
index 7061d6db..bee958d2 100644
--- a/plugins/shotwell-publishing/TumblrPublishing.vala
+++ b/plugins/shotwell-publishing/TumblrPublishing.vala
@@ -575,22 +575,6 @@ namespace Publishing.Tumblr {
internal class UploadTransaction : Publishing.RESTSupport.OAuth1.UploadTransaction {
//Workaround for Soup.URI.encode() to support binary data (i.e. string with \0)
- private string encode( uint8[] data ){
- var s = new StringBuilder();
- char[] bytes = new char[2];
- bytes[1] = 0;
- foreach( var byte in data )
- {
- if(byte == 0) {
- s.append( "%00" );
- } else {
- bytes[0] = (char)byte;
- s.append( Soup.URI.encode((string) bytes, ENCODE_RFC_3986_EXTRA) );
- }
- }
- return s.str;
- }
-
public UploadTransaction(Publishing.RESTSupport.OAuth1.Session
session,Spit.Publishing.Publishable publishable, string blog_url) {
debug("Init upload transaction");
@@ -605,18 +589,14 @@ namespace Publishing.Tumblr {
FileUtils.get_contents(base.publishable.get_serialized_file().get_path(), out payload,
out payload_length);
- string reqdata = this.encode(payload.data[0:payload_length]);
-
-
-
- add_argument("data[0]", reqdata);
+ add_argument("data64", Base64.encode(payload.data[0:payload_length]));
add_argument("type", "photo");
string[] keywords = base.publishable.get_publishing_keywords();
string tags = "";
if (keywords != null) {
tags = string.joinv (",", keywords);
}
- add_argument("tags", Soup.URI.encode(tags, ENCODE_RFC_3986_EXTRA));
+ add_argument("tags", tags);
} catch (FileError e) {
throw new Spit.Publishing.PublishingError.LOCAL_FILE_ERROR(
@@ -629,7 +609,7 @@ namespace Publishing.Tumblr {
Publishing.RESTSupport.Argument[] request_arguments = get_arguments();
assert(request_arguments.length > 0);
- var request_data = Publishing.RESTSupport.Argument.serialize_list(request_arguments);
+ var request_data = Publishing.RESTSupport.Argument.serialize_list(request_arguments, true,
false, "&");
Soup.Message outbound_message = new Soup.Message( "POST", get_endpoint_url());
outbound_message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY,
request_data.data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]