passport-changetip

0.0.1 • Public • Published

passport-changetip

ChangeTip Strategy for Passport. Easily add ChangeTip login support to your Node.JS application.

Install

$ npm install passport-changetip

Usage

First, acquire a ChangeTip Application ID and Secret. You'll then need to configure your strategy:

var ChangeTipStrategy = require('passport-changetip').Strategy;
 
passport.use(new ChangeTipStrategy({
    clientID: CHANGETIP_CLIENT_ID,
    clientSecret: CHANGETIP_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/changetip/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ changeTipID: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

You can now add an authenticate endpoint, and authenticate individual endpoints:

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

Package Sidebar

Install

npm i passport-changetip

Weekly Downloads

4

Version

0.0.1

License

MIT

Last publish

Collaborators

  • martindale