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
when i go to the google oauth to sign-in to my app it will loading infinite time .
solution :
1.create a separate file for create a passport strategy for google oauth
example code :
create a file : oauth.js
// required packages for oauth
const passport = require('passport')
const GoogleStrategy = require('passport-google-oauth2').Strategy
const User = require('./models/userSchema.js')
// passport-local config
// create a user strategy for a mongodb
passport.use(User.createStrategy())
// config for google oauth
passport.use(new GoogleStrategy({
clientID: "process.env.CLIENT_ID",
clientSecret: "process.env.CLIENT_SECRET",
callbackURL: "https://localhost:8888/auth/google/secrets"
},
(request, accessToken, refreshToken, profile, done)=> {
done(null, profile)
}
))
// Used to stuff a piece of information into a cookie
passport.serializeUser((user, done) => {
done(null, user)
})
// Used to decode the received cookie and persist session
passport.deserializeUser((user, done) => {
done(null, user)
})
now this get request will trigger to oauth google login/sign-in site without any error.
The text was updated successfully, but these errors were encountered:
TENSHKUMAR-KKT-2004
changed the title
Infinite loop occur when connecting to the google for sign in with Google.
Infinite loop occurred while connecting to the passport-google-oauth2 for "Sign in with Google".
Apr 11, 2023
issue :
solution :
example code :
inside app.js
In case, if you've written the function this way
inside app.js
it not work for us because it is a our server side request and response.
so we need to convert the code like this.
now this get request will trigger to oauth google login/sign-in site without any error.
The text was updated successfully, but these errors were encountered: