Created
March 26, 2013 14:27
-
-
Save sulmanen/5245760 to your computer and use it in GitHub Desktop.
Get twitter API 1.1 bearer token
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'); | |
var consumer_key = 'YOUR_CONSUMER_KEY'; | |
var consumer_secret = 'YOUR_CONSUMER_SECRET'; | |
var enc_secret = new Buffer(consumer_key + ':' + consumer_secret).toString('base64'); | |
var oauthOptions = { | |
url: 'https://api.twitter.com/oauth2/token', | |
headers: {'Authorization': 'Basic ' + enc_secret, 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}, | |
body: 'grant_type=client_credentials' | |
}; | |
request.post(oauthOptions, function(e, r, body) { | |
console.log(body) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment