Passport strategy for authenticating with PicsArt using the OAuth 2.0 API.
This module lets you authenticate using PicsArt in your Node.js applications. By plugging into Passport, PicsArt authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
$ npm install passport-picsart
The PicsArt authentication strategy authenticates users using a PicsArt account
and OAuth 2.0 tokens. The strategy requires a verify
callback, which receives the
access token and corresponding secret as arguments, as well as profile
which
contains the authenticated user's PicsArt profile. The verify
callback must
call done
providing a user to complete authentication.
In order to identify your application to PicsArt, specify the client ID,
client secret, and callback URL within options
. The client ID and secret
are obtained by creating an application at
PicsArt's developer site.
passport.use(new PicsartStrategy({
clientId: PICSART_CLIENT_ID,
clientSecret: PICSART_CLIENT_SECRET,
callbackURL: "http://127.0.0.1:3000/auth/picsart/callback"
},
function(accessToken, profile, done) {
User.findOrCreate({ picsartId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
Use passport.authenticate()
, specifying the 'picsart'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/picsart',
passport.authenticate('picsart'));
app.get('/auth/picsart/callback',
passport.authenticate('picsart', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
Copyright (c) 2015 PicsArt <http://www.picsart.com/>