Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature broken when using params argument with requests.get #38

Open
tonyxiao opened this issue Oct 2, 2012 · 2 comments
Open

Signature broken when using params argument with requests.get #38

tonyxiao opened this issue Oct 2, 2012 · 2 comments

Comments

@tonyxiao
Copy link

tonyxiao commented Oct 2, 2012

See sample code below

import requests, oauth_hook


hook = oauth_hook.OAuthHook(
    consumer_key='abcde',
    consumer_secret='fegdslaje',
)
c = requests.session(hooks={'pre_request': hook})

url = 'http://localhost:8888/utils/haha'
r =  c.get(url, params={
    'limit': 3,
})
print r, 'using params'
print r.url 
print r.request.url
print r.request.full_url

# prints the following
# <Response [404]> using params
# http://localhost:8888/utils/haha?oauth_nonce=28493927&oauth_timestamp=1349201520&oauth_consumer_key=abcde&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&limit=3&oauth_signature=wA4HFWbSNGBuaafDIAznbe0pI7E%3D&limit=3
# http://localhost:8888/utils/haha?oauth_nonce=28493927&oauth_timestamp=1349201520&oauth_consumer_key=abcde&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&limit=3&oauth_signature=wA4HFWbSNGBuaafDIAznbe0pI7E%3D
# http://localhost:8888/utils/haha?oauth_nonce=28493927&oauth_timestamp=1349201520&oauth_consumer_key=abcde&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&limit=3&oauth_signature=wA4HFWbSNGBuaafDIAznbe0pI7E%3D&limit=3

r =  c.get(url, data={
    'limit': 3,
})
print r, 'using data'
print r.url #, r.request.url
print r.request.url
print r.request.full_url

# prints the following
# <Response [404]> using data
# http://localhost:8888/utils/haha?oauth_nonce=28493927&oauth_timestamp=1349201520&oauth_consumer_key=abcde&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&limit=3&oauth_signature=wA4HFWbSNGBuaafDIAznbe0pI7E%3D
# http://localhost:8888/utils/haha?oauth_nonce=28493927&oauth_timestamp=1349201520&oauth_consumer_key=abcde&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&limit=3&oauth_signature=wA4HFWbSNGBuaafDIAznbe0pI7E%3D
# http://localhost:8888/utils/haha?oauth_nonce=28493927&oauth_timestamp=1349201520&oauth_consumer_key=abcde&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&limit=3&oauth_signature=wA4HFWbSNGBuaafDIAznbe0pI7E%3D

When using params argument together with requests.get, the limit parameter gets duplicated in the final url of the get request, resulting in an invalid signature as well as incorrect argument (limit now = [3,3] rather than just [3]).

@chrisdrackett
Copy link

I'm running into this as well, going to try and work out a fix if I can.

@chrisdrackett
Copy link

Didn't end up working on a fix as using data just 'fixes' the issues in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants