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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-twitter-signin

v0.0.5

Published

sets twitter oauth authentication on your node js express server specifically to handle the usage by a spa app

Downloads

20

Readme

node-twitter-signin

sets twitter oauth authentication on your node js express server specifically to handle the usage by a spa app

Install

  npm install --save node-twitter-signin

Usage

  const TwitterApi = require('node-twitter-signin');
  
  //really simple, right?
  app.use('/', TwitterApi(key, secret, callbackUrl, callback, callback_render ));
  
  /**
    key:  twitter app's consumer key
    secret: twitter app's consumer secret 
    callbackUrl: callback url. 
       In this case, using TwitterApi in the route '/', the url is 'http://localhost:3000/twitter/callback'
    
    callback: function that will be called giving you the authenticated user and its token.
      for example:
        function callback(user, token){
          //do whatever you want with the user and its token
          //like, save on the database, send a message through socketio to the client app, etc...
          console.log("user", user);
          console.log("token", token);

          //token has the properties below:
          //  -token (is the access_token)
          //  -secret (is the token secret)
          //  -request_token (is the related request_token )
        }

    callback_render: will be called giving the express 'res' object to allow you decide 
      what to send to the client when your callbackUrl is called.
      for example:
        function callback_render(res){
          res.json({
            'msg':'success'
          });
        }
  */

How it works

This module adds two routes into your express server.

  • GET /twitter/signin

    Your client side app should call this.

    This will return a http response with a json containing the property request_token.

    Do wathever you want with the request_token

    For instance, open a new window with 'https://api.twitter.com/oauth/authenticate?oauth_token='+request_token to allow the user do login on twitter.

  • GET /twitter/callback

    Twitter will call this route after the user types his credentials

Testing

The test command will open your chrome browser with twitter login page. (so you must have chrome installed)

Type your credentials.

If all tests pass, you should view the user and its token printed out on the console.

How to test

Open the file ./test/test.spec.js on the top of the file, insert your consumer key and consumer secret.

const key = 'TWITTER_CONSUMER_KEY'; //replace by yours
const secret = 'TWITTER_CONSUMER_SECRET'; //replace by yours

run the command

  npm run test