passport-cloudup

Build Status NPM version

Cloudup authentication for Passport

This module is based off passport-github

Install

$ npm install passport-cloudup --save

Usage

Configure Strategy

Cloudup uses OAuth 2.0 tokens to authenticate a registered Cloudup user. The returned profile contains the full Cloudup API user data.


passport.use(new cloudupStrategy({
  clientID: clientID,
  clientSecret: clientSecret,
  callbackURL: "/auth/cloudup/callback"
},
function(accessToken, refreshToken, profile, done){

  User.findOrCreate({cloudupId: profile.id}, function (err, user) {
    return done(err, user);
  });

}));

Authenticate Requests

Using express or connect-like middleware, specify the auth type of cloudup


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

app.get('/auth/cloudup/callback',
  passport.authenticate('cloudup'), function(req, res){
    if (req.user){
      res.redirect('/');
    }
    else {
      res.redirect('/login');
    }
  }
);

Examples

A full authentication example can be found here

Tests

$ npm install --dev
$ npm test

LICENSE MIT

Supported by

SEARCH FOR STRATEGIES

0STRATEGIES