所以我尝试使用Passport.js和Node.js登录Bungie.net。所以我使用了WindowsLive身份验证,但我真正想做的是从callbackURL抓取cookie并返回我的应用程序。有谁知道如何做到这一点?护照代码如下:
passport.use('windowslive', new WindowsLiveStrategy({
clientID: <my-app-id>,
clientSecret: <my-secret>,
callbackURL: "https://www.bungie.net/en/User/SignIn/Xuid"
},
function(accessToken, refreshToken, profile, cb) {
User.findOrCreate({ windowsliveId: profile.id }, function (err, user) {
return cb(err, user);
});
}
));
app.get('/auth/windows', passport.authenticate('windowslive'));
app.get('/auth/windows/callback', passport.authenticate('windowslive', {
successRedirect: '/success',
failureRedirect: '/error'
}));
app.get('/success', function(req, res, next) {
res.send('Successfully logged in.');
});
app.get('/error', function(req, res, next) {
res.send("Error logging in.");
});