PassportBnet是暴雪公司Battle.netOAuth服务认证的Passport策略。要使用这个,你需要在Battle.netDeveloperPortal上注册。
安装$ npm install passport-bnet用法配置
var BnetStrategy = require('passport-bnet').Strategy;var BNET_ID = process.env.BNET_IDvar BNET_SECRET = process.env.BNET_SECRET// Use the BnetStrategy within Passport.passport.use(new BnetStrategy({ clientID: BNET_ID, clientSecret: BNET_SECRET, callbackURL: "https://localhost:3000/auth/bnet/callback"}, function(accessToken, refreshToken, profile, done) { return done(null, profile);}));认证请求:
app.get('/auth/bnet', passport.authenticate('bnet'));app.get('/auth/bnet/callback', passport.authenticate('bnet', { failureRedirect: '/' }), function(req, res){ res.redirect('/'); });
评论