Created
August 30, 2017 18:10
-
-
Save jcipriano/330b708f45cc909d0213abe6f11c597f to your computer and use it in GitHub Desktop.
Verifies Twitter credentials.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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