passport-untappd
v1.0.0
Published
Untappd authentication strategy for Passport.
Downloads
4
Maintainers
Readme
passport-untappd
Passport strategy for authenticating with Untappd using the OAuth 2.0 API.
Install
$ npm install passport-untappd
Usage
Configure Strategy
The Untappd authentication strategy authenticates users using an Untappd 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 an app ID, app secret, callback URL.
passport.use(new UntappdStrategy({
clientID: 'UNTAPPD_CLIENT_ID',
clientSecret: 'UNTAPPD_CLIENT_SECRET',
callbackURL: 'https://www.example.net/auth/untappd/callback'
}, function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ untappdId: profile.id }, function(err, user) {
done(err, user);
});
});
Authenticate Requests
Use passport.authenticate()
, specifying the 'untappd'
strategy, to authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/untappd', passport.authenticate('untappd'));
app.get('/auth/untappd/callback',
passport.authenticate('untappd', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
License
Copyright (c) 2015 Shuhei Kagawa