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
The email isn't returned in the Passport Google OAuth 2.0 strategy.
Detailed Description
I'm using the Passport Google OAuth 2.0 strategy to authenticate users in my application. However, when users authorize my application, the email isn't included in the profile object returned by Google. This is problematic as I require access to the user's email address for my application's functionality.
here is my code below
// 1-Googlepassport.use(newGoogleStrategy({clientID: process.env.CLIENT_ID,clientSecret: process.env.CLIENT_SECRET,callbackURL: process.env.GOOGLE_CALLBACK_URL,},asyncfunction(accessToken,refreshToken,profile,done){try{console.log(profile);const[user,created]=awaitmodels.User.findOrCreate({where: {googleId: profile.id},defaults: {username: profile.displayName,email: profile.emails ? profile.emails[0].value : null,// Check if emails array existsprofilePicture: profile.photos ? profile.photos[0].value : null,// Check if photos array exists},});returndone(null,user);// Return the user instance}catch(error){returndone(error);// Pass any error to the done callback}}));passport.serializeUser((user,done)=>{done(null,user);});passport.deserializeUser((user,done)=>{done(null,user);});router.get("/google",passport.authenticate("google",{scope: ["profile","email"]}));router.get("/google/callback",passport.authenticate("google",{failureRedirect: "/signIn"}),function(req,res){// Successful authentication, redirect home.res.redirect("/");});
the profile object dosen't include the emails property even when i make the email in scope
The text was updated successfully, but these errors were encountered:
passport-google-oauth20?
The email isn't returned in the Passport Google OAuth 2.0 strategy.
Detailed Description
I'm using the Passport Google OAuth 2.0 strategy to authenticate users in my application. However, when users authorize my application, the email isn't included in the profile object returned by Google. This is problematic as I require access to the user's email address for my application's functionality.
here is my code below
the profile object dosen't include the emails property even when i make the email in scope
The text was updated successfully, but these errors were encountered: