node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »


Build Status

Passport strategy for authenticating with using the OAuth 2.0 API.

This module lets you authenticate using in your Node.js applications. By plugging into Passport, authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.


$ npm install passport-twitchtv


Configure Strategy

The authentication strategy authenticates users using a account and OAuth tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a consumer key, consumer secret, and callback URL.

A scope is required, all scopes are available here

passport.use(new TwitchtvStrategy({
    callbackURL: "",
    scope: "user_read"
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ twitchtvId: }, function (err, user) {
      return done(err, user);

Authenticate Requests

Use passport.authenticate(), specifying the 'twitchtv' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/twitchtv', passport.authenticate('twitchtv'));
  passport.authenticate('twitchtv', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home. 


For a complete, working example, refer to the login example.


$ npm install --dev
$ make test

Build Status



The MIT License

Copyright (c) 2014 John Kernke