Verify_credentials returns code 400 every time - no error

ios
nodejs
oauth

#1

I’m trying to verify a user token which i got from my iOS client via my node.js server.
I’m using node.js with request module.

This is my code:

var postData = {
consumer_key:“key”,
consumer_secret:“secret”,
token:authToken,
token_secret:authTokenSecret
}

var options = {
url: ‘https://api.twitter.com/1.1/account/verify_credentials.json’,
body: postData,
json: true,
method: ‘GET’
}

request(options, function (error, response, body) {
if(error){
return console.log(‘Twitter - Error:’, error);
}

//Check for right status code
if(response.statusCode !== 200){
    return console.log('Twitter - Invalid Status Code Returned:', response.statusCode);
}
// Do stuff

});

I really am a bit lost here trying to figure out this issue,
Any help will be appreciated.


#2

It looks like your request is missing some things, try the calls with something like https://github.com/ttezel/twit that will take care of the proper OAuth headers in requests for you.


#3

Well, if feel kind of silly right now, after seeing the library you suggested, i compared it to the Twitter Library i’m using, and i seemed to miss the REST API for validation. I will try to make it work, in case it won’t, ill use your suggestion.

Thanks Igor!