[英]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.