Skip to content

Instantly share code, notes, and snippets.

@ciaranj
Forked from polotek/node-oauth-access-token.js
Created January 23, 2011 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciaranj/792011 to your computer and use it in GitHub Desktop.
Save ciaranj/792011 to your computer and use it in GitHub Desktop.
With these changes everything seems to work just peachy-fine for me. Is your Application configured as a 'client' type rather than a browser type? (Client is correct for pin verification)
var fs = require('fs');
OAuth = require('oauth').OAuth;
// Your Twitter Application type must be 'client' and not 'browser' for pin verification.
var oa = new OAuth("http://twitter.com/oauth/request_token"
, "http://twitter.com/oauth/access_token"
, config.consumerKey
, config.consumerSecret
, "1.0"
, null
, "HMAC-SHA1");
var args= process.argv;
if( args.length < 3) {
oa.getOAuthRequestToken(function(err, oauth_token, oauth_token_secret, results){
if(err) throw err;
// Now send the user to a browser with the address:
// console.error(arguments);
console.log("Please visit here:\n " + "http://twitter.com/oauth/authenticate?oauth_token="+ oauth_token) ;
console.log("When you have got your pin, please execute this command: ")
console.log(" " + args[0] +" "+ args[1] + " " + oauth_token + " " + oauth_token_secret + " <your_pin_number>")
});
} else {
var token= args[2];
var token_secret= args[3];
var pin= args[4];
oa.getOAuthAccessToken(token
, token_secret
, pin // authorize PIN goes here
, function(error, oauth_access_token, oauth_access_token_secret, results2) {
console.error(arguments);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment