julianlam / nodebb-plugin-sso-facebook

Single Sign-On Plugin for NodeBB
BSD 2-Clause "Simplified" License
19 stars 19 forks source link

Facebook Login / Registration Returns the wrong email #13

Closed KanwalPrakashSingh closed 8 years ago

KanwalPrakashSingh commented 9 years ago

Hi Guys, The FB login returns @facebook.com as email. Why is this happening? The app (facebook app) is having full permissions to access the email , then why does this wrong email id received

There seems to be a problem in passport-facebook, in response i view these two fields { "name": "xcscsc", "id": "23232323232323" }

julianlam commented 9 years ago

Hi @KanwalPrakashSingh, the idea is:

I do not remember if we have access to the emails, but I'll look into it soon...

KanwalPrakashSingh commented 9 years ago

But the permissions in my app created on FB, does have access to emails

murphomatic commented 9 years ago

I'm having the same issue - Facebook app lists email as an approved item, yet the sso plugin defaults to the generic @facebook.com email address.

julianlam commented 9 years ago

Hello @KanwalPrakashSingh @murphomatic -- apologies for my inattention.

During testing, I have discovered that we do pass in the email scope as part of the OAuth process. At this point, when a user authorizes through Facebook, they are presented with this dialog:

selection_058

If at this point they click "Edit the info you provide" and uncheck "email", then the NodeBB (and by extension, the plugin) will not have access to the email, and will fall back to fbid@facebook.com. If they leave it as is (checked), then the email goes through as expected and is saved appropriately with their user account.

Perhaps revoke authorization for NodeBB from your Facebook user settings, and attempt a reconnection again? At this point, I cannot reproduce the issue.

murphomatic commented 9 years ago

What’s odd is that I have the app set to ask permission for email, and I allow access to email when connecting (not unchecking anything) .. but still get the facebook.com email address. I've tried revoking the app and reconnecting - same behavior.

pic1

pic2

KanwalPrakashSingh commented 9 years ago

@murphomatic @julianlam same is the case with me

andrejjama commented 8 years ago

Same here. E-mail in Facebook permission popup is checked etc., but nodeBB user profile email is fbid@facebook.com

antreos commented 8 years ago

Same here.

julianlam commented 8 years ago

To help me debug, please add console.log(profile); after the highlighted line in library.js, restart NodeBB, and try to log in. Let me know what the server outputs in the log.

https://github.com/julianlam/nodebb-plugin-sso-facebook/blob/e042fac332908b136030cdd3063a221cdb960d36/library.js#L61

luofan189 commented 8 years ago

The issue is that the API requires to explicitly to specify the profile fields you want to include in the response. I created a PR to fix this: https://github.com/julianlam/nodebb-plugin-sso-facebook/pull/22

Feel free to merge it if you think it is OK, @julianlam

julianlam commented 8 years ago

v1.1.4

julianlam commented 8 years ago

Thanks @luofan189! I'm sure many people were bothered by this :)

I suppose I was using an old version of the Facebook API...