passport-cnood
v2.1.2
Published
Passport strategy for CNOOD OAuth 2.0
Downloads
2
Readme
passport-cnood
Passport strategy for CNOOD OAuth 2.0
Installation
$ npm install passport-cnood -S
Usage
Configure Strategy
const Strategy = require('passport-cnood');
passport.use(new Strategy({
clientID: EXAMPLE_CLIENT_ID,
clientSecret: EXAMPLE_CLIENT_SECRET,
callbackURL: 'http://localhost:3000/auth/cnood/callback',
}, (accessToken, refreshToken, profile, done) => {
done(null, profile);
}));
Authenticate Requests
app.get('/auth/cnood', passport.authenticate('cnood'));
app.get('/auth/cnood/callback', passport.authenticate('cnood', {
failureRedirect: '/login'
}), handleFun);
Koa middleware
const API = require('passport-cnood').API;
const app = koa();
API(app);
app.use(function*() {
const data1 = yield this.API.get(url, data, config);
const data2 = yield this.API.post(url, data, config);
// ...
});
License
MIT