node package manager

passport-distimo

Distimo authentication strategy for Passport.

Passport-Distimo

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

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

Install

$ npm install passport-distimo

Usage

Configure Strategy

There are no user profiles in Distimo API. So the profile will contain only a provider ID ('distimo' in our case).

passport.use(new DistimoStrategy({
    clientID: DISTIMO_CLIENT_ID,
    clientSecret: DISTIMO_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/distimo/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    // profile contains only provider id ('distimo')
    // Process accessToken and refreshToken
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

Credits

License

The MIT License

Copyright (c) 2014 Konstantin Tsabolov <LinkedIn profile>