我遵循 Passport js page 中给出的代码示例。
app.get('/fbconnect', function (req, res) {
var loadingMessage = "Connecting to Facebook. Please Wait";
res.render('index', { title : 'Home', message : DEFAULT_MESSAGE, loadingMessage : loadingMessage, loadingDivDisplay : "block"}, function(err, html) {
if (!err) {
passport.authenticate('facebook', { scope : ['email', 'publish_actions'] })(req, res);
}
});
});
app.get('/auth/facebook/callback', function (req, res) {
var loadingMessage = "Processing the request. Please wait",
isAuthenticationError = false;
if(req.query && req.query.error){
req.session.authError = req.query.error;
req.session.authErrorReason = req.query.error_reason;
isAuthenticationError = true;
}
res.render('index', { title : 'Home', message : DEFAULT_MESSAGE, loadingMessage : loadingMessage, loadingDivDisplay : "block"}, function(err, html){
if (isAuthenticationError === true) {
res.redirect('/');
} else {
console.log("into right place");
passport.authenticate('facebook', { successRedirect: '/authorisationComplete'})(req, res);
}
});
});
但是我面临一些我自己的服务器问题,这需要很长时间,然后在身份验证后显示网关超时问题。
我试图在从 FB 进行身份验证后立即从我的服务器显示一条消息(例如“正在处理请求。请稍候”),而需要 2 分钟的时间才能达到网关超时。
但是失败了。有人可以帮忙吗