You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
if(user) {
// if found,set this user as a req.user
return done(null, user);
}
else {
// if not found, create the user and set it as req.user
User.create({
name: profile.displayName,
email: profile.emails[0].value,
password: crypto.randomBytes(20).toString('hex'),
}, function(err, user) {
if (err) {
console.log("Error in creating user google strategy-passport", err); return; }
return done(null, user);
});
}
});
}
));
module.exports.passport; '
The text was updated successfully, but these errors were encountered:
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; '
The text was updated successfully, but these errors were encountered: