passport-facebook: User email is NOT returned from facebook signup
Hi,
We use nodejs with passport-facebook for user to signup account with fb account. Recently we found that the passport-facebook is not returning the email. Anyone has the idea?
We have already defined the fields
passport.use('facebook', new FacebookStrategy({
clientID: fb.clientID,
clientSecret: fb.clientSecret,
callbackURL: fb.callbackURL,
profileFields: ['id', 'email', 'name']
}, function(accessToken, refreshToken, profile, done) {
And also the scope
passport.authenticate('facebook', { scope: ['email', 'public_profile'] })
Would appreciate your help. thanks!
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 20
Facebook is shit, developpers are getting crazy for standard shit like this. it’s my 10th install (5+ different scripting languages and libs to fb connect) and everytime i cry. hope it helps
here’s my working data :
passport.use(new FacebookStrategy({ clientID: ‘xxxxx’, clientSecret: ‘xxxxxxxx’, callbackURL: “http://localhost:3000/auth/facebook/callback”, profileFields: [‘id’, ‘displayName’, ‘email’, ‘birthday’, ‘friends’, ‘first_name’, ‘last_name’, ‘middle_name’, ‘gender’, ‘link’] }, function(accessToken, refreshToken, profile, cb) { User.findOrCreate({ facebookId: profile.id }, function (err, user) { return cb(err, user); }); } )); app.get(‘/auth/facebook’, passport.authenticate(‘facebook’, { authType: ‘rerequest’, scope: [‘user_friends’, ‘email’, ‘public_profile’], } )); app.get(‘/auth/facebook/callback’, passport.authenticate(‘facebook’, { failureRedirect: ‘/login’, }), function(req, res) { res.redirect(‘/’); } );
@VulcanRav Thanks for the tips but I already checked them. I’m using my own account. I only have an email address and no phone number. But the result contains just
nameandid. Theemailfield is not present at all.No
emailfield here either. The only things I get back arenameandid. That’s all. Even withprofileFieldsandscopedeclared. Any ideas?This is a pain in 2020
and
email is empty 👎
Please check your Facebook app/page permission list for those still struggling to get email information. By default, public_profile permission is given. you have to add email to the permission list to make it work
Have the same issue, scope and postFields didn’t work, Will remove the shit FB login from the website, that’s waste of time. 😡
For anyone seeing this in the future, you have to do 2 things:
and
and it will (or may?) work.
@rafipiccolo solution worked. It seems like they need to update the api call from 2.4 to 2.9