Open cmatta opened 9 years ago
Thanks for reporting this, it seems like the signature is not being built up correctly. Were you able to look through #109? Did that help at all?
Getting an signature_invalid error when working with SmugMug and using a query string in the request.
Session requests work well with SmugMug API (api.smugmug.com) except when a query is added. Both examples work when used in a browser window with proper authorization.
This example works: https://api.smugmug.com/api/v2/node/GS0g9!children
This example fails: https://api.smugmug.com/api/v2/node/GS0g9!children?start=11&count=10
The string built within session is
https://api.smugmug.com/api/v2/node/GS0g9!children
&count=10?oauth_consumer_key=...?oauth_nonce=...?oath_signature_method=...?oauth_timestamp=...?oauth_token=...?oauth_version=...
?start=11
Note the first part of the query string "?start=11" is moved to the end of the Uri yet "&count=10" is left in place.
The failed example is created when calling session.get("https://api.smugmug.com/api/v2/node/GS0g9!children?start=11&count=10",headers={'Accept': 'application/json'})
The same call without the query string "?start=11&count=10" works.
Using python3 (3.4.1) with rauth 0.7.2 Using OAuth1Session to create the session.
Sounds like a bug in the query string encoding.
Switched from rauth to requests_oauthlib and works well now. No changes to query string necessary.
This is a problem when the query string is included in a GET request via the 'url' parameter, rather than added as separate 'params'.
this will work: session.request('GET', 'https://example.com', params={'key': 'value'}, header_auth=True)
this will produce an invalid signature: session.request('GET', 'https://example.com?key=value', header_auth=True)
What happens is the base string for the oauth signature strips out the query string and completely discards it. What needs to happen is for the query string to be stripped out and then included in the base string in the same way as if they were provided as a dict to 'params'. I think the way to do this is OAuth1Session.request normalises the above 2 example calls.
Reference Appendix A.5.1. Generating Signature Base String at https://oauth.net/core/1.0a/#anchor13
Hello, I'm trying to upload an image to flickr and receiving a
signature_invalid
error.This code should reproduce:
The response I get is
401
and the response text saysoauth_problem=signature_invalid
.I see this is related to the closed issue #109, if this should go in that closed thread I'll move it.