Oauth/request_token not working properly


I’m trying to get the oauth request_token for Twitter as described here, making a call to “oauth/request_token”: https://dev.twitter.com/docs/auth/implementing-sign-twitter

I’m generating the params using the encode_params function in here: https://github.com/sixohsix/twitter/blob/master/twitter/oauth.py

I then wrap the returned string in a dict with they key “Authorization” and dump it into the Headers of the Post request I’m making using the python request library. Here’s the two lines I use to create the request.

ep = "OAuth " + auth.encode_params(baseUrl, method, params)
response = requests.post(baseUrl+method, headers={ "Authorization" : ep})

The eventual header looks like this (consumer_key modified):

{'Accept': '*/*',
 'Accept-Encoding': 'gzip, deflate, compress',
 'Authorization': 'OAuth oauth_callback=http%253A%252F%252Fec2-54-244-189-248.us-west-2.compute.amazonaws.com%252Fct%252Ftwitter_login_handler%252F&oauth_consumer_key=c444PKNYYFsFLIrrTsbA&oauth_nonce=14937468581358710045&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1366568033&oauth_version=1.0&oauth_signature=kiYucZzPY%2FXy2WyJliJ6YcggVzQ%3D',
 'Content-Length': '0',
 'User-Agent': 'python-requests/1.2.0 CPython/2.7.3 Linux/3.5.0-21-generic'}

However, I’m still getting a 401 response that says: ‘Failed to validate oauth signature and token’

Any idea what I’m doing wrong? Any help would really be appreciated.


Did you get an answer