twitter-pin
v1.0.0
Published
A dead simple Twitter PIN-based authorization module
Downloads
66
Maintainers
Readme
twitter-pin
A dead simple Twitter PIN-based authorization module.
The PIN-based OAuth flow is intended for applications which cannot access or embed a web browser in order to redirect the user to the authorization endpoint. Examples of such applications would be command-line applications, embedded systems, game consoles, and certain types of mobile apps.
Twitter / Developers / Documentation / OAuth / PIN-based authorization
Installation
npm install twitter-pin
Usage
The twitter-pin module should be initialzied with the consumerKey
and
consumerSecret
issued by Twitter when you register your Twitter
application. After registering click "manage
keys and access tokens" under the apps "Application Settings".
var twitterPin = require('twitter-pin')(consumerKey, consumerSecret)
twitterPin.getUrl(function (err, url) {
if (err) throw err
console.log('1) Open:', url)
console.log('2) Enter PIN:')
process.stdin.once('data', function (pin) {
twitterPin.authorize(pin.toString().trim(), function (err, result) {
if (err) throw err
console.log(result) // => { token: '...',
// secret: '...',
// user_id: 0,
// screen_name: '...' }
})
})
})
License
MIT