passport-geekpark
v1.0.1
Published
Official passport strategy for authenticating to GeekPark
Downloads
3
Readme
passport-geekpark
Official passport strategy for authenticating to GeekPark, base on passportjs.
Usage
- register an application at geekpark.net
npm i passport-geekpark --save
- config passport (id, secret, callback url)
Example
const passport = require('koa-passport');
const config = require('./index');
const GeekParkStrategy = require('../passport-geekpark');
module.exports = () => {
const User = require('../models/user');
passport.serializeUser((user, done) => {
done(null, user.id);
});
passport.deserializeUser((id, done) => {
User.findOne({ id }).then(d => done(null, d));
});
passport.use(
new GeekParkStrategy({
clientID: config.oauth.id,
clientSecret: config.oauth.secret,
callbackURL: config.oauth.callback,
}, (token, tokenSecret, profile, done) => {
done(null, profile);
})
);
};
Tip
If you are using < Node 6.0
, you need babel transform for ES6 class
.