Skip to content

Instantly share code, notes, and snippets.

@jcipriano
Created August 30, 2017 18:10
Show Gist options
  • Save jcipriano/330b708f45cc909d0213abe6f11c597f to your computer and use it in GitHub Desktop.
Save jcipriano/330b708f45cc909d0213abe6f11c597f to your computer and use it in GitHub Desktop.
Verifies Twitter credentials.
var nconf = require('nconf')
var request = require('request')
// load config
nconf.file({ file: 'config.json' }).env()
// twitter authentication
var twitter_oauth = {
consumer_key: nconf.get('TWITTER_CONSUMER_KEY'),
consumer_secret: nconf.get('TWITTER_CONSUMER_SECRET'),
token: nconf.get('TWITTER_ACCESS_TOKEN'),
token_secret: nconf.get('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