Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

215 error while requesting Token from Twitter oAuth API

I'm trying to Implement Twitter login in my NodeJS app.

As per the documentation from Twitter, I need to pass the below parameters to this url via POST request. URL:

https://api.twitter.com/oauth/request_token

PARAMETERS:

 oauth_nonce=, 
 oauth_signature=, 
 oauth_callback="http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback", 
 oauth_signature_method="HMAC-SHA1",       
 oauth_timestamp="currentTimestamp", 
 oauth_consumer_key=“myKEY”, 
 oauth_version="1.0"

I'm passing a random string for oauth_nonce parameter. I'm not clear on how to create a oauth_signature?

I keep getting 215 error whenever I make the POST request beacuse of incorrect oauth_nonce and oauth_signature values I guess.

How do I generate oauth_nonce and oauth_signature values while making the request in NodeJS.

like image 555
Anirudh Avatar asked Jul 19 '18 07:07

Anirudh


People also ask

Why is Twitter API not working?

Check that your authentication credentials are correct. You can check or regenerate your App keys and tokens in the Apps section of your developer dashboard (under “Details”). Check that you have properly authorized your OAuth 1.0a request with oauth_nonce , oauth_signature , and oauth_timestamp for your request.

How do I get a Twitter request token?

Generating access tokens Login to your Twitter account on developer.twitter.com. Navigate to the Twitter app dashboard and open the Twitter app for which you would like to generate access tokens. Navigate to the "Keys and Tokens" page. Select 'Create' under the "Access token & access token secret" section.


1 Answers

Those parameters need to be passed in your authorization header:

OAuth oauth_nonce="K7ny27JTpKVsTgdyLdDfmQQWVLERj2zAK5BslRsqyw", 
oauth_callback="http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback", 
oauth_signature_method="HMAC-SHA1", 
oauth_timestamp="1300228849", 
oauth_consumer_key="OqEqJeafRSF11jBMStrZz", 
oauth_signature="Pc%2BMLdv028fxCErFyi8KXFM%2BddU%3D", 
oauth_version="1.0"

But before that, you need to get a signature, which will then give you all of the parameters above. Check the documentation here.

A recommendation would be to use a 3rd party library like passport, which heavily simplifies this process if needed.

like image 82
Rodrigo Mata Avatar answered Oct 23 '22 04:10

Rodrigo Mata