jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.29k stars 446 forks source link

Facebook allow Email scope not working, It's not return "email" ? #290

Open bombkiml opened 1 year ago

bombkiml commented 1 year ago

Scope allow :

app.get('http://localhost/authentication/facebook', passport.authenticate('facebook', { 
    scope: ['email', 'public_profile'] 
}));

Result:

{
  id: '5900246411513451',
  username: undefined,
  displayName: 'John Wick',
  name: { familyName: 'Wick', givenName: 'John', middleName: undefined },
  gender: undefined,
  profileUrl: undefined,
}

Why without email return ????

sgarner commented 1 year ago

You have to tell the library which fields from the profile to fetch, using the profileFields option when you call the FacebookStrategy constructor:

new FacebookStrategy({
  clientID,
  clientSecret,
  callbackURL,
  profileFields: ['id', 'email', 'name'],
})
0gebey commented 11 months ago

I am also trying the same thing but it doesn't work even with the 'email' field inside the 'profileFields'

dev-george-nikolaidis commented 9 months ago

Hey, did someone come with solution?

bombkiml commented 9 months ago

Hey, did someone come with solution?

Hi bro, I can fix by add Permissions. Must allow Permissions facebook profile fields : https://developers.facebook.com/docs/graph-api/reference/v13.0/user#readperms

new FacebookStrategy({
  clientID,
  clientSecret,
  callbackURL,
  profileFields: ['id', 'email', 'name'],
})