Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Google strategy not returning gender and birthay #23

Open
boulepick opened this issue Jun 27, 2022 · 0 comments
Open

Google strategy not returning gender and birthay #23

boulepick opened this issue Jun 27, 2022 · 0 comments

Comments

@boulepick
Copy link

boulepick commented Jun 27, 2022

this is my implementation and everything that I tried it will not return the gender and birthday as indicated in the documentation

GOOGLE_FIELDS='id,birthday,email,gender,family_name,given_name,locale,picture,profile'
GOOGLE_SCOPE='profile,email,openid,https://www.googleapis.com/auth/user.birthday.read,https://www.googleapis.com/auth/user.gender.read'

passport.use(new GoogleStrategy({
    clientID: process.env.GOOGLE_CLIENTID,
    clientSecret: process.env.GOOGLE_SECRET,
    callbackURL: process.env.GOOGLE_CALLBACK,
    profileFields: process.env.GOOGLE_FIELDS.split(','),
    passReqToCallback: true,
    enableProof: true,
  },
  (async (req, token, tokenSecret, profile, next) => {
    try {
      const addedParam = JSON.parse(req.query.state);
      const action = addedParam.action || 'l';
      const memberType = addedParam.member;
      const {
        id,
        family_name,
        given_name,
        email,
        gender, // always null
        birthday, // always null
        picture,
      } = profile;

am I doing something wrong or is this not implemented in this strategy, as I understand to get these fields from google documentation you need to make a call to the people api like so: https://people.googleapis.com/v1/people/me?personFields=genders,birthdays

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant