passport-depositphotos
v1.0.5
Published
Depositphotos passport stratagy.
Downloads
1
Maintainers
Readme
passport-depositphotos
An abstract class implementing Passport's strategy API.
Install
$ npm install passport-depositphotos
Usage
This module use an abstract Strategy
class that is intended to be
subclassed when implementing concrete authentication strategies. Once
implemented, such strategies can be used by applications that utilize Passport
middleware for authentication.
Configure Strategy
The Depositphotos authentication strategy authenticates users using a Depositphotos account.
The strategy requires a verify
callback, which accepts
these credentials and calls done
providing a user, as well as options
specifying a API key.
passport.use(new DepositphotosStrategy({
apiKey: process.env.DEPOSITPHOTOS_API_KEY,
}, function(accessToken, profile, done) {
User.findOrCreate({ depositphotosId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'depositphotos'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/depositphotos',
passport.authenticate('depositphotos'));
app.get('/auth/depositphotos/callback',
passport.authenticate('depositphotos', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
Tests
$ npm install
$ npm test
Credits
License
Copyright (c) 1988-2017 Oleksii Volkov <https://ovolkov.pro/>