0.2.0 • Published 10 years ago

passport-distimo v0.2.0

Weekly downloads
1
License
-
Repository
github
Last release
10 years ago

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 always be an empty object.

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 is an empty object
    // 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>