Ebeo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Signing of request with 3-legged OAuth token does not work #365

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following code does not work for me with revision 1003:

<code>
string token = "<a working 3-L OAuth token>"
    tokenSecret = "<the OAuth token secret>";
DocumentsService service = new DocumentsService("GoogleDocumentsSample");
GOAuthRequestFactory requestFactory = new 
GOAuthRequestFactory(service.ServiceIdentifier, "GoogleDocumentsSample");
requestFactory.ConsumerKey = "anonymous";
requestFactory.ConsumerSecret = "anonymous";
requestFactory.Token = token;
requestFactory.TokenSecret = tokenSecret;
service.RequestFactory = requestFactory;

DocumentQuery query = new 
DocumentQuery("https://docs.google.com/feeds/default/private/full");

// Execute the query:
int count = service.Query(query).Entries.Count;
</code>

The query fails with an HTTP 401 that contains "Unknown authorization 
header" in the response body.  This bug reproduces ONLY if the token 
contains a character that needs to be escaped (in my case, the second 
character is always a "/" but maybe this is not always true).

I can use the same token & secret with the Java client and it works 
correctly (i.e. I'm sure that the token is valid).

It looks like the token needs to be double escaped when computing the base 
string for signing.  URL encoding the token in the caller code (i.e. in the 
sample above) does not work because the token itself is invalid.

Revision 1005 (in /branches/Experimental) demonstrates a fix, but I'm not 
sure if that is the "correct" solution and if anything else (2-l OAuth) 
might break.

Original issue reported on code.google.com by j...@google.com on 7 Apr 2010 at 1:32

GoogleCodeExporter commented 9 years ago
I created a different set of fixes. I think i have that all working now, but we 
never know until you try. 

Original comment by fman...@gmail.com on 26 May 2010 at 8:06