Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/picsart/passport-picsart
PicsArt authentication strategy for PassportJS
https://github.com/picsart/passport-picsart
Last synced: about 1 month ago
JSON representation
PicsArt authentication strategy for PassportJS
- Host: GitHub
- URL: https://github.com/picsart/passport-picsart
- Owner: PicsArt
- License: mit
- Created: 2014-10-27T09:24:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-05T09:21:39.000Z (about 10 years ago)
- Last Synced: 2023-02-26T16:22:58.393Z (almost 2 years ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 29
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# passport-picsart
[![Build](https://travis-ci.org/PicsArt/passport-picsart.png)](http://travis-ci.org/PicsArt/passport-picsart)
[![Dependencies](https://david-dm.org/PicsArt/passport-picsart.png)](http://david-dm.org/PicsArt/passport-picsart)[Passport](http://passportjs.org/) strategy for authenticating with [PicsArt](http://www.picsart.com/)
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](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).## Install
$ npm install passport-picsart
## Usage
#### Configure Strategy
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](https://dev.picsart.com/apps) at
PicsArt's [developer](https://dev.picsart.com/) 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);
});
}
));#### Authenticate Requests
Use `passport.authenticate()`, specifying the `'picsart'` strategy, to
authenticate requests.For example, as route middleware in an [Express](http://expressjs.com/)
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('/');
});## License
[The MIT License](http://opensource.org/licenses/MIT)
Copyright (c) 2015 PicsArt <[http://www.picsart.com/](http://www.picsart.com/)>