Giter VIP home page Giter VIP logo

Comments (5)

netpoetica avatar netpoetica commented on August 15, 2024 1

@jaredhanson What is the appropriate path for making sure that the solution to this problem isn't just "don't use a proxy"? I don't think the issue will be able to be solved in the light layer of passport - it's much deeper in the oauth lib. Just as an FYI there is a PR here for it: ciaranj/node-oauth#294

Maybe with a request coming from you, the author of oauth lib will consider merging this PR, which will allow you to close this open issue. I'm quite certain every other passportjs plugin/strategy has the exact same problem though

from passport-google-oauth.

rajolichandra avatar rajolichandra commented on August 15, 2024

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)
at ClientRequest.emit (events.js:95:17)
at CleartextStream.socketErrorListener (http.js:1547:9)
at CleartextStream.emit (events.js:95:17)
at Socket.onerror (tls.js:1440:17)
at Socket.emit (events.js:117:20)
at net.js:440:14
at process._tickCallback (node.js:419:13)

PassportJs Code

app.get('/auth/google', passport.authenticate('google', { session: false,
accessType: 'offline',
approvalPrompt: 'force' }));

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

function(accessToken, refreshToken, profile, done) {
    console.log(params.expires_in);
    console.log(profile.id);
    process.nextTick(function() {           
        // try to find the user based on their google id
        User.findOne({ 'google.id' : profile.id }, function(err, user) {
            if (err)
                return done(err);

            if (user) {
                // if a user is found, log them in
                return done(null, user);
            } else {
                // if the user isnt in our database, create a new user
                var newUser          = new User();

                // set all of the relevant information
                newUser.google.id    = profile.id;
                newUser.google.token = accessToken;
                newUser.name = profile.displayName;
                newUser.google.name  = profile.displayName;
                newUser.google.email = profile.emails[0].value; // pull the first email

                console.log(profile.id);
                console.log(accessToken);
                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);
                });
            }
        });
    });

})); 

from passport-google-oauth.

rajolichandra avatar rajolichandra commented on August 15, 2024

Hi,

Can you please provide the solution for the above issue ??

from passport-google-oauth.

kalinichenko avatar kalinichenko commented on August 15, 2024

I ran into the same problem and in my case using a proxy server caused a problem. To be more specific an error was occurred doing a POST to https://accounts.google.com/o/oauth2/token
glad if it helps.

from passport-google-oauth.

sourav2029 avatar sourav2029 commented on August 15, 2024

As @kalinichenko mentioned , the error is because you are behind a proxy , Try running it without proxy . Hope it should work beacause it worked for me .

from passport-google-oauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.