Created
January 10, 2018 19:35
-
-
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.
This file contains 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 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