Notoriously Problematic Merge
Wondering what’s next for npm?Check out our public roadmap! »

twitter-pin

1.0.0 • Public • Published

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

Build status js-standard-style

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

Install

npm i twitter-pin

DownloadsWeekly Downloads

6

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar