Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate a Twitter access token from the server

The client is able to authenticate using hello.js to facebook and send the access token back to the server which then does a get graph.facebook.com/me?access_token=xx and if it is correct returns the user's profile info.

I want to do the same for Twitter but even after reading the documentation I don't understand which endpoint I should hit.Is it possible to do it with a REST call?

like image 758
arisalexis Avatar asked Oct 23 '25 21:10

arisalexis


1 Answers

You need to hit this endpoint

https://dev.twitter.com/rest/reference/get/account/verify_credentials

like that (using the request module):

const oauth={
    consumer_key:config.get('twitter.consumerKey'),
    consumer_secret:config.get('twitter.consumerSecret'),
    token:oauthToken,
    token_secret:oauthTokenSecret
  }

  requestAsync({
    url:'https://api.twitter.com/1.1/account/verify_credentials.json',
    method:'GET',
    oauth,
  })
like image 87
arisalexis Avatar answered Oct 27 '25 04:10

arisalexis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!