Skip to content

Instantly share code, notes, and snippets.

@sulmanen
Created March 26, 2013 14:27
Show Gist options
  • Save sulmanen/5245760 to your computer and use it in GitHub Desktop.
Save sulmanen/5245760 to your computer and use it in GitHub Desktop.
Get twitter API 1.1 bearer token
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