passport-facebook icon indicating copy to clipboard operation
passport-facebook copied to clipboard

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

Open bombkiml opened this issue 1 year ago • 4 comments

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 ????

bombkiml avatar Mar 30 '23 14:03 bombkiml

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'],
})

sgarner avatar May 11 '23 00:05 sgarner

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

0gebey avatar Sep 12 '23 12:09 0gebey

Hey, did someone come with solution?

dev-george-nikolaidis avatar Nov 05 '23 07:11 dev-george-nikolaidis

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'],
})

bombkiml avatar Nov 09 '23 08:11 bombkiml