JSPM

twitter-pin

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q41943F
  • License MIT

A dead simple Twitter PIN-based authorization module

Package Exports

  • twitter-pin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (twitter-pin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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

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