[英]passport.js facebook authentication next not working
我尝试实施的passport.js策略是针对facebook提供者的策略。 我已经测试了教科书示例(来自https://github.com/passport/express-4.x-facebook-example ),似乎从未调用过重定向。
重定向序列可以正常工作,除非用户登录后可以重定向到主页,即使在回调中显式放置其他URL也不例外。
因此,除最后一次重定向外,其他所有操作均正常进行,该重定向最终应在https://xx.com/testing处结束,但永远不会发生。
nodejs 6,Express 4+,护照3.2
怎么了?
战略
passport.use(new FacebookStrategy({
clientID: xx,
clientSecret: 'xx',
callbackURL: 'https://xx.com/auth/facebook/callback/',
profileFields: ['id', 'email', 'name', 'displayName']
},
function (accessToken, refreshToken, profile, done) {
return done(null, profile)
}
))
路线
router.get('/auth/facebook', passport.authenticate('facebook', {scope: ['public_profile', 'email']}))
router.get('/auth/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/login' }),
function(req, res) {
// never gets called
console.log('I don't get called!!!')
res.redirect('/testing')
})
/testing
进入成功successRedirect
passport.authenticate('facebook', {
successRedirect: '/testing',
failureRedirect: '/login'
}));
更新:使用passport.authorize
router.get('/auth/facebook/callback',
passport.authorize('facebook', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/testing')
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.