UNPKG

passport-wunderlist

Version:

Wunderlist authentication strategy for Passport.

63 lines (47 loc) 1.88 kB
# passport-wunderlist Wunderlist OAuth 2.0 authentication strategy for [Passport](http://passportjs.org/). This module lets you authenticate using Wunderlist in your Node.js applications. By plugging into Passport, OAuth 2.0 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-wunderlist ## Usage #### Configure Strategy The Wunderlist authentication strategy authenticates users using a Wunderlist account and OAuth 2.0 tokens. The provider's OAuth 2.0 endpoints, as well as the client identifer and secret, are specified as options. The strategy requires a `verify` callback, which receives an access token and profile, and calls `cb` providing a user. ```js passport.use(new WunderlistStrategy({ clientID: EXAMPLE_CLIENT_ID, clientSecret: EXAMPLE_CLIENT_SECRET, callbackURL: "http://localhost:3000/auth/example/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOrCreate({ exampleId: profile.id }, function (err, user) { return cb(err, user); }); } )); ``` #### Authenticate Requests Use `passport.authenticate()`, specifying the `'wunderlist'` strategy, to authenticate requests. For example, as route middleware in an [Express](http://expressjs.com/) application: ```js app.get('/auth/example', passport.authenticate('wunderlist')); app.get('/auth/example/callback', passport.authenticate('wunderlist', { failureRedirect: '/login' }), function(req, res) { // Successful authentication, redirect home. res.redirect('/'); }); ``` ## License [The MIT License](http://opensource.org/licenses/MIT) Copyright (c) 2017 Bram Pellens <[http://www.brampellens.be/](http://www.brampellens.be/)>