Skip to content

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 ...

This comment has been minimized.

Copy link

yOpenSource commented Oct 9, 2019

@skaterdav85 Nice handy snippet for OAuth 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.