passport-eipsk-strategy

Build Status Coverage Status NPM Version

Passport strategy for authenticating with EIPSK using the OAuth 2.0 API.

Install

$ npm i passport-eipsk-strategy

Usage

Configure Strategy

var passport = require('passport'),
    EipskStrategy = require('passport-eipsk-strategy').Strategy;

passport.use(new EipskStrategy({
    clientID: '<app id>',
    clientSecret: '<secret key>',
    callbackURL: 'http://localhost:3000/auth/eipsk/callback'
  },
  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({eipskId: profile.id}, function (err, user) {
      return cb(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

app.get('/auth/eipsk',
  passport.authenticate('eipsk'));

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

License

The MIT License

SEARCH FOR STRATEGIES

0STRATEGIES