Sign querystring parameters in OAuth 1.0
authorMarty Alchin <marty@martyalchin.com>
Tue, 19 Jun 2012 04:02:51 +0000 (21:02 -0700)
committerMarty Alchin <marty@martyalchin.com>
Tue, 19 Jun 2012 04:02:51 +0000 (21:02 -0700)
Existing usage doesn't pass GET querystring parameters along to oauthlib,
so it wasn't signing those properly, which causes problems with APIs that
rely heavily on GET parameters. By passing in r.full_url instead of r.url,
oauthlib can parse out the correct parameters and sign them properly.

requests/auth.py

index 314f793..2ae2703 100644 (file)
@@ -83,12 +83,12 @@ class OAuth1(AuthBase):
                 # to preserve body. 
                 r.headers['Content-Type'] = 'multipart/form-encoded'
                 r.url, r.headers, _ = self.client.sign(
-                    unicode(r.url), unicode(r.method), None, r.headers)
+                    unicode(r.full_url), unicode(r.method), None, r.headers)
             else:
                 # Normal signing
                 r.headers['Content-Type'] = 'application/x-www-form-urlencoded'
                 r.url, r.headers, r.data = self.client.sign(
-                    unicode(r.url), unicode(r.method), r.data, r.headers)
+                    unicode(r.full_url), unicode(r.method), r.data, r.headers)
 
             # Having the authorization header, key or value, in unicode will
             # result in UnicodeDecodeErrors when the request is concatenated