Open akakum921 opened 2 years ago
Is your app configured with the correct client ID and secret?
Yes, I cross checked it
@jaredhanson seems that Google changed a lot in their auth flow https://developers.google.com/identity/protocols/oauth2/openid-connect#server-flow The token url (https://oauth2.googleapis.com/token) doesn't match the one used in this strategy.
I am getting this error after choosing the google account for signing in InternalOAuthError: Failed to obtain access token at Strategy.OAuth2Strategy._createOAuthError (C:\Users\sairam\Desktop\nodews\codeial\node_modules\passport-oauth2\lib\strategy.js:423:17) at C:\Users\sairam\Desktop\nodews\codeial\node_modules\passport-oauth2\lib\strategy.js:177:45 at C:\Users\sairam\Desktop\nodews\codeial\node_modules\oauth\lib\oauth2.js:191:18 at ClientRequest. (C:\Users\sairam\Desktop\nodews\codeial\node_modules\oauth\lib\oauth2.js:162:5)
at ClientRequest.emit (events.js:400:28)
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
This is the passport google strategy
' const passport = require('passport'); const googleStrategy = require('passport-google-oauth').OAuth2Strategy; const crypto = require('crypto');
const User = require("../models/user");
//tell passport to use a new strategy for google login
passport.use(new googleStrategy({ clientID: GOOGLE_CLIENT_ID, clientSecret: GOOGLE_SECRET, callbackURL: 'http://localhost:8000/users/auth/google/callback', }, function(accessToken, refreshToken, profile, done){ // find a user User.findOne({email: profile.emails[0].value}).exec(function(err, user) { if(err) { console.log("Error in google strategy-passport", err); return; } // console.log(accessToken); console.log(profile);
}
));
module.exports.passport; '