Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
get bearer token from Twitter REST API for application-only authentication
const request = require('request');
const credentials = `${process.env.CONSUMER_KEY}:${process.env.CONSUMER_SECRET}`;
const credentialsBase64Encoded = new Buffer(credentials).toString('base64');
url: '',
headers: {
'Authorization': `Basic ${credentialsBase64Encoded}`,
body: 'grant_type=client_credentials'
}, function(err, resp, body) {
console.log(body); // the bearer token ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment