Passport Bnet 是暴雪公司 Battle.net OAuth 服务认证的 Passport 策略。要使用这个,你需要在 Battle.net Developer Portal 上注册。
$ npm install passport-bnet
配置
var BnetStrategy = require('passport-bnet').Strategy; var BNET_ID = process.env.BNET_ID var 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('/'); });