node.js - Twitter API, "Unable to verify your credentials." -


exactly says on tin.

by means, code should working. it's following https://dev.twitter.com/oauth/application-only page says. yet, keeps returning {{"errors":[{"code":99,"message":"unable verify credentials","label":"authenticity_token_error"}]} [finished in 0.551s], , have no idea why.

var request = require('request');  var options = {   url: 'https://api.twitter.com/oauth2/token',   method: 'post',   headers: {     "authorization": "basic " + new buffer("[key]:[secretkey]").tostring('base64'),     "content-type":"application/x-www-form-urlencoded;charset=utf-8"   },   body: "grant_type=client_credentials" };  request.post(options, function(error, response, body){   console.log(body); }); 

as quick note, key , secretkey omitted code here due inherent sensitivity of being present. can place own key/secretkey in there try it, unwilling provide own.

thanks!

edit:

the issue contenttype should've been content-type, , technically fixed it, in reality changed error getting.

update:

transcoding buffer key base64 , shows integrity of authorization key remains intact throughout encoding process, , basic [base64keyhash] valid according documentation provided twitter.

since specifying method: "post" in options, try use request() instead of request.post():

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(options, function(error, response, body){   if(error) {     console.log(error);   } else {     console.log(response.statuscode, body);   } }); 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -