Search code examples
node.jspassport.jsfacebook-authentication

Facebook-passport strategy not returning emails field


I am using Facebook v2.5 API.

route :

app.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));

config :

passport.use(new FacebookStrategy({

        clientID: CLIENTID,
        clientSecret: CLIENTSECRET,
        callbackURL: callbackURL,
        profileFields: ["emails", "displayName", "gender"]
    },

    function (token, refreshToken, profile, done) {
        console.log(profile) 

        ...
    }));

profile does not have "emails" field.

I tried passing scope as an array too

scope : ['email']

Solution

  • I just had the same problem: using my test account and working with the scopes, I suddenly "lost" the email address, no way to get it again using all the hints found here.

    Curiously using a new facebook account, the email address appeared.

    => I went to my test account in facebook and revoked all rights for my app there. Afterwards I logged into my app again and granted all the rights needed. Since then I receive the email address again.

    Hope this helps.