Skip to content

Instantly share code, notes, and snippets.

View yOpenSource's full-sized avatar
🎯
Focusing

yOpenSource

🎯
Focusing
View GitHub Profile
@iamdtang
iamdtang / gist:be8b4cc9558b3b6ab6cbef23150debe2
Created November 29, 2017 00:44
get bearer token from Twitter REST API for application-only authentication
require('dotenv').config();
const request = require('request');
const credentials = `${process.env.CONSUMER_KEY}:${process.env.CONSUMER_SECRET}`;
const credentialsBase64Encoded = new Buffer(credentials).toString('base64');
request({
url: 'https://api.twitter.com/oauth2/token',
method:'POST',
headers: {