Https://api.twitter.com/oauth/request_token return 401 unauthorized


#1

I am trying to connect to Twitter though oAuth.I am making a POST request to the API https://api.twitter.com/oauth/request_token.

Here is is example of my Base signature string

POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Fapi.ec2.phunware.com%252Fapi%252Ftwitter%26oauth_consumer_key%3D6jq5dNZcccoPbApAJ0sOaA%26oauth_nonce%3DN2ZiMjViYzhlMDUxNDIyZWIwYjQ4NmU0ZjM1MDg4NTY%3D%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1362843354%26oauth_version%3D1.0

I used the tool http://quonos.nl/oauthTester/ to verify my base signature.

Here is the corresponding header

OAuth oauth_callback=“http%3A%2F%2Fapi.ec2.phunware.com%2Fapi%2Ftwitter”,oauth_consumer_key=“6jq5dNZcccoPbApAJ0sOaA”,oauth_nonce=“N2ZiMjViYzhlMDUxNDIyZWIwYjQ4NmU0ZjM1MDg4NTY=”,oauth_signature_method=“HMAC-SHA1”,oauth_signature=“7ney2RxElbHUl2t1Jnz57pQpmFs%3D”,oauth_timestamp=“1362843354”,oauth_version=“1.0”

I tried the following command in my MAC terminal

curl --request ‘POST’ ‘https://api.twitter.com/oauth/request_token’ --header ‘Authorization: OAuth oauth_callback=“http%3A%2F%2Fapi.ec2.phunware.com%2Fapi%2Ftwitter”,oauth_consumer_key=“6jq5dNZcccoPbApAJ0sOaA”,oauth_nonce=“N2ZiMjViYzhlMDUxNDIyZWIwYjQ4NmU0ZjM1MDg4NTY=”,oauth_signature_method=“HMAC-SHA1”,oauth_signature=“7ney2RxElbHUl2t1Jnz57pQpmFs%3D”,oauth_timestamp=“1362843354”,oauth_version=“1.0”’ --verbose

And i get 401 unauthrized error. I tried to set the oauth_callback =“oob” but I still get the same error.


#2

Have you verified your timestamp is in sync with Twitter’s? On the step where you create your signature, are you using a “composite key” of your consumer secret and the “null” oauth token secret (example: “2dq5dZNdccoPcDpDJ0sOaJ&”)


#3

Hi Taylor,
Facing same issue,
I already mailed you request_token url, with valid parameters.
Please suggest.
Regards,
Kiran K


#4

Hi,
I am facing the same problem error Error 401 Unauthorized which was working fine.I am htting the url curl --get -k ‘https://stream.twitter.com/1.1/statuses/filter.json’ --data ‘follow=145125358’ --header ‘Authorization: 1OAuth oauth_consumer_key=“LIiCC1QQsUufkwHLLt3ZDA”, oauth_nonce=“b1177c3bf28b445a84ccce612c7db1f2”, oauth_signature=“Azb9avx7p5Q9pObvs%2BkV5mQla34%3D”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1379411748”, oauth_token=“262090009-QPDO59nD5jQwOytzB7ZlVfEHuau64sdpCXTkbPNE”, oauth_version=“1.0”’;

this was working fine some time back but now its generating error i have not not make any changes in the app.


#5

What have you tried so far to probe what may have gone wrong? Is the system clock correct on your machine? Can you use the access token to make other API requests?