Open dzeitman opened 9 years ago
Try entering a string instead of a number:
twitterPinAuth.authorize("0056956", ...
Same errors: I've tried it as both number and a string value. [Error: The PIN number you have entered is incorrect!]
Steps to reproduce:
twitterPinAuth.requestAuthUrl() .then(function(url) { console.log(url); /// Copy this into a browser and accept and copy the PIN. }).catch(function(err) { console.error(err); });
3: Run Script again and "authorize" using the PIN (as String or Number - either fails)
twitterPinAuth.authorize('PIN NUMBER HERE') .then(function(data) { console.log(data.accessTokenKey); console.log(data.accessTokenSecret); }).catch(function(err) { console.error(err); });
UPDATE- Not clear why, but seems you can't re-run the script for step 3 - it must be done in same login sequence / script.
Workaround :
Added prompt lib.
npm install prompt
var prompt = require('prompt');
then before step 3: Add: prompt.start();
prompt.get(['pin'], function (err, result) { if (err) { return onErr(err); } console.log('Command-line input received:'); console.log(' PIN: ' + result.pin);
twitterPinAuth.authorize(result.pin)
.then(function(data) {
console.log(data.accessTokenKey);
console.log(data.accessTokenSecret);
}).catch(function(err) {
console.error(err);
});
});
function onErr(err) { console.log(err); return 1; }
Prompt will display a prompt in the terminal for a PIN - copy the pin number into terminal and hit enter.
Function will then return tokens as expected.
Steps to reproduce:
Set up new twitter app in admin console - get keys
var TwitterPinAuth = require('twitter-pin-auth'); var twitterPinAuth = new TwitterPinAuth('', '');
twitterPinAuth.requestAuthUrl() .then(function(url) { console.log(url);
}).catch(function(err) { console.error(err); });
Responds with a url like this: https://twitter.com/oauth/authorize?oauth_token=uhZz6wAAAAAAibonAAABUL78Rb0
Open in a browser and see pin: 0056956 // like this re-run script calling authorize with the pin:
twitterPinAuth.authorize(0056956, function(err, data) { if(err) { return console.error(err); } console.log(data.accessTokenKey);
console.log(data.accessTokenSecret);
});
It only returns an error.
[Error: The PIN number you have entered is incorrect!]
Thoughts?