Login with Facebook not getting email

569 views
Skip to first unread message

Mel

unread,
Aug 7, 2015, 10:13:03 PM8/7/15
to LoopbackJS
Hi all,

I am using Loopback with loopback-component-passport, loopback-connector-mysql to implement a login with Facebook and Google.

Everything is working pretty well except one thing: I cannot get the email from the user when he logs in with Facebook, instead I have something like: 1015318643102.....@loopback.facebook.com

I do not have any problem with Google, I can get the email, I am including the email in the scope and when I check with Facebook debugger, I can see the email in the scope.

Any idea where the problem could be?

Thanks a lot,

Mel

Raymond Feng

unread,
Aug 7, 2015, 11:06:06 PM8/7/15
to loopb...@googlegroups.com
Did you allow apps to see your email on facebook? Check your authorizations on fb.

Sent from my iPhone 6 Plus
--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/719516c9-5c1f-4a26-9ab2-65d1eb83169d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mel

unread,
Aug 7, 2015, 11:21:20 PM8/7/15
to LoopbackJS
Hi Raymond,

Yes, I also tried with different Facebook accounts but still cannot get the email. In the useridentity table, I only see the displayName, name and id (I can see emails, photos for Google login).

Thanks

Raymond Feng

unread,
Aug 8, 2015, 1:21:33 AM8/8/15
to loopb...@googlegroups.com
Try the following:

2. Find LoopBack Demo App
3. Click on Edit Settings
4. Make sure Email address is checked.

I can see the email using Facebook login using loopback-example-passport.

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

Mel

unread,
Aug 8, 2015, 2:34:26 AM8/8/15
to LoopbackJS
So I tried with the loopback-example-passport, just changed the Facebook ID and Secret, with a new app I created on Facebook.

Same result, works perfectly with Google, and it works with Facebook, but I am just not getting the email. I tried with 3 different accounts, all have email checked (blue disc with white check).

Mel

unread,
Aug 9, 2015, 6:24:25 AM8/9/15
to LoopbackJS
Here is the JSON object I am getting in the loopback-passport module, I have the same result with other users. I still cannot figure out why I an not getting the email.


{ id: '1015306499.......',
  username
: undefined,
  displayName
: 'Mel ...',
  name
:  
   
{ familyName: undefined,
     givenName
: undefined,
     middleName
: undefined },
  gender
: undefined,
  profileUrl
: undefined,
  provider
: 'facebook',
  _raw
: '{"name":"Mel ...","id":"1015306499......."}',
  _json
: { name: 'Mel ...', id: '1015306499.......' }
}


From to to time I also have :

InternalOAuthError: Failed to fetch user profile
but it happens completely randomly.

Mel

unread,
Aug 16, 2015, 8:14:55 AM8/16/15
to LoopbackJS
Hi,

I tried again with a clean install of loopback-example-passport, created a new Facebook app and tried with 3 different facebook accounts, and I am only getting the name and the user Id of Facebook, I am not getting any email, profile picture, gender, .... but works perfectly with Google.

I have no clue what to do now, this "Login with Facebook" feature is supposed to be a main feature of my app but I completely stuck now.

Anybody had that problem before?

Thanks a lot for any help,

Mel,

Mel

unread,
Aug 16, 2015, 9:30:14 AM8/16/15
to LoopbackJS
FYI I just tested with Firebase Auth service and it's working perfectly, and I get all the information from Facebook (email, picture) , so I know it's not coming from my Facebook app, or Facebook account and permissions.

Mel

unread,
Aug 16, 2015, 11:54:34 AM8/16/15
to LoopbackJS
So after checking the source code, I finally got it working by adding something like this in my config, I couldn't find any mention in the doc though about profile Fields. Not sure why I need to add this.

  "profileFields": ["id", "email", "last_name", "first_name", "gender", "is_verified"]

Anyway thanks,

Mel

Raymond Feng

unread,
Aug 16, 2015, 12:08:25 PM8/16/15
to loopb...@googlegroups.com
Great. This SO thread seems to be the same - http://stackoverflow.com/questions/20291357/passport-facebook-cant-get-about-me-and-email-profile-fields. We'll see if it can be added to our docs.


Sent from my iPhone 6 Plus

Zvi Eintracht

unread,
Apr 7, 2016, 10:27:48 PM4/7/16
to LoopbackJS, ar...@chinesepod.com
Hi Mel,
To what file are you adding this line?
I am encountering the same problem you reported, and it can be avoided by changing passport strategy.js, see details here: https://github.com/strongloop/loopback-example-passport#4-facebook-profile-info . However as this involved modifying a file in node_modules it is far from elegant. I would much rather follow your solution. Where should this "profileFields" be placed?

Thanks much,
Zvi

Alex Megalokonomos

unread,
Apr 8, 2016, 2:13:34 AM4/8/16
to loopb...@googlegroups.com
That line should be added to the facebook-login config section in providers.json.


Mel

unread,
Apr 8, 2016, 4:56:32 AM4/8/16
to LoopbackJS
Yup, that's it, example:

  "facebook-login": {
    "provider": "facebook",
    "module": "passport-facebook",
         "failureFlash": true,
    "profileFields": ["id", "email", "gender", "is_verified", "languages", "picture.type(large)", "name", "verified"]
  },
  "google-login": {
    "provider": "google",
    "module": "passport-google-oauth",

Zvi Eintracht

unread,
Apr 8, 2016, 6:25:44 PM4/8/16
to LoopbackJS
awesome, thanks Alex, Mel !
Zvi

Mel

unread,
Apr 8, 2016, 8:20:20 PM4/8/16
to LoopbackJS
BTW I sometimes have those emails from Facebook users:


Not sure why, maybe the user is blocking the email on their side but I am not sure how to do that, it seems that the email is included in the basic profile so if you block it you basically block everything.
Reply all
Reply to author
Forward
0 new messages