npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

twitter-login

v1.1.5

Published

Twitter Login package using oAuth v1.0

Readme

npm-version GitHub issues GitHub forks GitHub license

Twitter Login. OAuth 1.0 flow

Selling Point

This package can be used to get Twitter user access token using oAuth 1.0 flow.

Implements a Client-Side flow for login with twitter, similar to one provided by Facebook and Google. This can be used to get User Access Token to make API calls to Twitter where User Context is required

Installation:

  • Clone as a Git repository

    git clone https://github.com/knitesh/twitter-login.git
  • Install as a node_module

    npm i twitter-login --save
    
    OR
    
    npm install twitter-login --save

Usage

To start twitter Login process

await twitter.login()

To get user details

await twitter.callback(auth, tokenSecret)

Sample Express app

const express = require('express')
const session = require('express-session')
const TwitterLogin = require('twitter-login')

const app = express()
const port = 9000

const sessionConfig = {
  user: null,
  tokenSecret: null,
  secret: 'keyboard cat',
}

app.use(session(sessionConfig))

// get consumer key and consumer secret from Twitter App setting
const twitter = new TwitterLogin({
  consumerKey: '<your api key>',
  consumerSecret: '<your api secret key>',
  callbackUrl: 'http://localhost:$port/twitter/auth/userToken',
})

// Route where user will get directed on clicking on Login button
app.get('/twitter/auth', async (req, res) => {
  try {
    const result = await twitter.login()
    // Save the OAuth token secret for use in your /twitterauth/userToken Callback route
    req.session.tokenSecret = result.tokenSecret
    // Redirect to the /twitterauth/userToken route, with the OAuth responses as query params
    res.redirect(result.url)
  } catch (err) {
    // Handle Error here
    res.send('Twitter login error.')
  }
})

// Callback Route to retreive user auth token and secret
// This needs to be whitelisted in your twitter app
app.get('/twitter/auth/userToken', async (req, res) => {
  try {
    const oAuthParam = {
      oauth_token: req.query.oauth_token,
      oauth_verifier: req.query.oauth_verifier,
    }

    // call function passing Auth and Token Secret
    const userInfo = await twitter.callback(
      oAuthParam,
      req.session.tokenSecret,
    )
    // Delete the tokenSecret securely
    delete req.session.tokenSecret
    // Add User Info to your session
    req.session.user = userInfo
    // Redirect to route that can extract user detail
    res.redirect('/')
  } catch (err) {
    // Handle Error here
    res.send('Twitter login error.')
  }
})

app.get('/', (req, res) => {
  const _user = req.session && req.session.user
  if (_user) {
    res.send(JSON.stringify(_user))
  } else {
    res.send('Login with Twitter -http://localhost:9000/twitter/auth')
  }
})

app.listen(port, () => {
  console.log('Example app listening at http://localhost:${port}')
})