Hello!
I’m trying to write a small program in node.js to get going with working with the Twitter API, however, I’m running into an error, and I have no clue why.
Everything that’s supposed to be there is there, to the best of my knowledge. It doesn’t look like anything’s missing. It doesn’t look like anything’s broken. But when it gets back, it’s broken.
Code is here:
var request = require(‘request’);
var options = {
url: 'https://api.twitter.com/oauth2/token',
method: 'POST',
headers: {
"Authorization": "Basic " + new Buffer("[key]:[secretkey]").toString('base64'),
"contentType":"application/x-www-form-urlencoded;charset=UTF-8"
},
body: "grant_type=client_credentials"
};
request.post(options, function(error, response, body){
console.log(body);
});