gpt4 book ai didi

node.js - Passport -facebook Strategy.parseErrorResponse

转载 作者:太空宇宙 更新时间:2023-11-04 02:00:06 25 4
gpt4 key购买 nike

我正在尝试设置 Facebook 身份验证,每当调用回调函数时都会收到错误,它会在/node_modules/passport-facebook/lib/strategy.js:196:12 处抛出 Strategy.parseErrorResponse

没有消息告诉我出了什么问题。我检查以确保我的 clientID 和密码正确(据我所知,如果它们错误,可能会发生这种情况)。

    passport.use(new FacebookStrategy({
clientID: myId,
clientSecret: mySeceret,
callbackURL: callBackUrl,
passReqToCallback : true
}, (req, accessToken, refreshToken, profile, done) => {
process.nextTick(() => {
if (req.user) {
done(null, req.user);
if (!req.user.facebookId) {
req.user.facebookId = profile.id;

req.user.save().then(() => {
done(null, req.user);
});
} else {
done(null, req.user);
}
} else {
User.find({where: {facebookId: profile.id}}, function (err,user) {
return done(err, user);
});
}
});
}));

我的路线

app.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' }));
app.get('/auth/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/login' }),
function (req, res) {
res.redirect('/');
});

全栈

Error
at Strategy.parseErrorResponse (/node_modules/passport-facebook/lib/strategy.js:196:12)
at Strategy.OAuth2Strategy._createOAuthError (/node_modules/passport-oauth2/lib/strategy.js:376:16)
at /node_modules/passport-oauth2/lib/strategy.js:166:45
at /node_modules/oauth/lib/oauth2.js:191:18
at passBackControl (/node_modules/oauth/lib/oauth2.js:132:9)
at IncomingMessage.<anonymous> (/node_modules/oauth/lib/oauth2.js:157:7)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)

此外,看起来 key 正在被传递,因为它包含我可以看到正在调用的路由/auth/facebook/callback?code="someReallyLongKey"

最佳答案

我今天遇到了完全相同的问题。发生这种情况是因为我的服务器无法连接到 Mongo 数据库。我重新启动了 mongod 服务,一切开始按预期工作

关于node.js - Passport -facebook Strategy.parseErrorResponse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46327209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com