-2

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']
Arbaz Siddiqui
  • 441
  • 2
  • 10

2 Answers2

0

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.

Chrigel
  • 16
  • 3
  • How do you revoke app rights? Having the same problem, can't see where FB allows me to manage rights. – Dan Donaldson Jan 22 '16 at 02:27
  • @DanDonaldson: go in your FB account to settings, then to apps. There you should see all the apps using your FB account for login. Select an app and edit the access rights or revoke them. – Chrigel Jan 26 '16 at 15:25
0

Make sure you define "email" scope while login, then you could get it when you ask graph.facebook.com:

$url = 'https://www.facebook.com/dialog/oauth';
$params = array(
    'client_id' => $this->strategy['app_id'],
    'redirect_uri' => $this->strategy['redirect_uri'],
    'scope' => 'email',
);