简体   繁体   English

500的NodeJ在处理时无法获取访问令牌(错误:连接ECONNREFUSED)._ tickCallback(node.js:419:13)

[英]NodeJs, 500 failed to obtain access token (Error: connect ECONNREFUSED) at at process._tickCallback (node.js:419:13)

I am using passport GoogleStrategy to authenticate users, but i am getting below error. 我正在使用护照GoogleStrategy对用户进行身份验证,但出现错误。 Can you please help me ? 你能帮我么 ?

Code

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);
                });
            }
        });
    });

Error Log 错误记录

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. 500无法在D:\\ Chandrasekhar \\ NodeJs_Workspace \\ SkillsetMgmtNode \\ node_modules \\ passport-google-oauth \\ node_modules \\ passport-oauth \\ lib \\ passport-oauth \\ strategies \\ oauth2.js:125获取访问令牌(错误:连接ECONNREFUSED): 38位于D:\\ Chandrasekhar \\ NodeJs_Workspace \\ SkillsetMgmtNode \\ node_modules \\ passport-google-oauth \\ node_modules \\ passport-oauth \\ node_modules \\ oauth \\ lib \\ oauth2.js:177:18。 (D:\\Chandrasekhar\\NodeJs_Workspace\\SkillsetMgmtNode\\node_modules \\passport-google-oauth\\node_modules\\passport-oauth\\node_modules\\oauth\\lib\\oauth2.js:148:5) (D:\\ Chandrasekhar \\ NodeJs_Workspace \\ SkillsetMgmtNode \\ node_modules \\ passport-google-oauth \\ node_modules \\ passport-oauth \\ node_modules \\ oauth \\ lib \\ oauth2.js:148:5)

I too was getting the same error . 我也遇到了同样的错误。 For me the error was because i was behind a proxy . 对我来说,错误是因为我在代理后面。 When run without proxy the code worked fine . 在没有代理的情况下运行时,代码工作正常。 So try this once . 因此,尝试一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM