gpt4 book ai didi

javascript - NodeJs,500 无法获取访问 token (错误 : connect ECONNREFUSED) at at process. _tickCallback (node.js:419:13)

转载 作者:太空宇宙 更新时间:2023-11-03 22:36:41 24 4
gpt4 key购买 nike

我正在使用 Passport GoogleStrategy 来验证用户身份,但出现以下错误。你能帮我吗?

代码

passport.use(new GoogleOAuth2Strategy({
clientID : configAuth.googleAuth.clientID,
clientSecret: configAuth.googleAuth.clientSecret,
callbackURL: configAuth.googleAuth.callbackURL,
scope: ['profile', 'email', 'openid'],
passReqToCallback : true
},


function(token, refreshToken, profile, done) {
// User.findOne won't fire until we have all our data back from Google

process.nextTick(function() {
console.log(profile.id);
User.findOne({ 'google.id' : profile.id }, function(err, user) {
if (err)
return done(err);
if (user) {
return done(null, user);
} else {
var newUser = new User();
newUser.google.id = profile.id;
newUser.google.token = token;
newUser.google.name = profile.displayName;
newUser.google.email = profile.emails[0].value;
console.log(profile.id);
console.log(token);
console.log(profile.displayName);
console.log(profile.emails[0].value);

// save the user
newUser.save(function(err) {
if (err)
throw err;
return done(null, newUser);
});
}
});
});

错误日志

500 failed to obtain access token (Error: connect ECONNREFUSED) at D:\Chandrasekhar\NodeJs_Workspace\SkillsetMgmtNode\node_modules\passport-google-oauth\node_modules\passport-oauth\lib\passport-oauth\strategies\oauth2.js:125:38 at D:\Chandrasekhar\NodeJs_Workspace\SkillsetMgmtNode\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\oauth\lib\oauth2.js:177:18 at ClientRequest. (D:\Chandrasekhar\NodeJs_Workspace\SkillsetMgmtNode\node_modules \passport-google-oauth\node_modules\passport-oauth\node_modules\oauth\lib\oauth2.js:148:5)

最佳答案

我也遇到了同样的错误。对我来说,错误是因为我位于代理后面。当没有代理运行时,代码运行良好。所以尝试一次。

关于javascript - NodeJs,500 无法获取访问 token (错误 : connect ECONNREFUSED) at at process. _tickCallback (node.js:419:13),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26780760/

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