README
Passport-VerticalResponse
Passport strategy for authenticating with VerticalResponse using the OAuth 2.0 API.
This module lets you authenticate using VerticalResponse in your Node.js applications. By plugging into Passport, VerticalResponse authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Usage
Configure Strategy
The Vertical Response authentication strategy authenticates users using a Vertical Response
account and OAuth 2.0 tokens. The strategy requires a verify
callback, which
accepts these credentials and calls done
providing a user, as well as
options
specifying a app ID, app secret, and callback URL.
passport.use(new VerticalResponseStrategy({
clientID: VERTICALRESPONSE_APP_ID,
clientSecret: VERTICALRESPONSE_APP_SECRET,
callbackURL: "http://localhost:3000/auth/verticalresponse/callback"
}, function (accessToken, refreshToken, profile, done) {
User.findOrCreate({ VerticalResponseId: profile.id }, function(err, user) {
return done(err, user);
});
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'verticalresponse'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/verticalresponse', passport.authenticate('verticalresponse'));
app.get('/auth/verticalresponse/callback',
passport.authenticate('verticalresponse', { failureRedirect: '/login' }),
function(req, res) {
// Successul authentication, redirect home.
res.redirect('/');
});
Credits
Created by Cyril Gaillard
Code based on passport-campaignmonitor by Jared Hanson