1.0.0 • Published 7 years ago

passport-addressix-oauth2 v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

A simple Passport strategy for Addressix OAuth2.

Install

npm install passport-addressix-oauth2

Usage

Register the strategy

var AddressixStrategy = require('passport-addressix-oauth2').Strategy;

passport.use(new AddressixStrategy({
  clientID: ADDRESSIX_CLIENT_KEY,
  clientSecret: ADDRESSIX_CLIENT_SECRET,
  callbackURL: "http://127.0.0.1:3000/auth/callback"
}, function(accessToken, refreshToken, profile, done) {
   User.findOrCreate({ exampleId: profile.id }, function (err, user) {
      return cb(err, user);
    });
}));

Authenticate Requests

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

For example, as route middleware in an Express application:

app.get('/someroute/example',
  passport.authenticate('addressix'));

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

Related Modules

License

The MIT License