Skip to content

Instantly share code, notes, and snippets.

@jcipriano
Created January 10, 2018 19:35
Show Gist options
  • Save jcipriano/936ba3ed9f78f647eba839fdc824d78b to your computer and use it in GitHub Desktop.
Save jcipriano/936ba3ed9f78f647eba839fdc824d78b to your computer and use it in GitHub Desktop.
Validates your Twitter consumer keys and tokens by logging requestor's user object.
var request = require('request')
// twitter authentication
var twitter_oauth = {
consumer_key: 'TWITTER_CONSUMER_KEY',
consumer_secret: 'TWITTER_CONSUMER_SECRET',
token: 'TWITTER_ACCESS_TOKEN',
token_secret: 'TWITTER_ACCESS_TOKEN_SECRET'
}
// update request options
request_options = {
url: 'https://api.twitter.com/1.1/account/verify_credentials.json',
oauth: twitter_oauth
}
// get current user info
request.get(request_options, function (error, response, body) {
if (error) {
console.log('Error retreiving user data.')
console.log(error)
return;
}
console.log(body)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment