1

I've been trying to setup auth provider login with facebook. I've followed the instructions online, have generated an authentication handler and customised.

However when I try logging in (through community) the facebook Auth.UserData passed into createUser method does not contain a username, email, first name or last name. It does however have the full name.

Is there something in the config (either Salesforce side or within my Facebook app) that I am missing?

Any help would be greatly appreciated!

2 Answers 2

8

Fill the field 'User Info Endpoint URL' (on Auth provider page ) with this and test it out. https://graph.facebook.com/me?fields=first_name,last_name,email

Reason for suggestion is: Facebook api v2.2, 2.3 returns first name, last name, email etc by default. Facebook api v2.4 and later versions don't return these fields unless we specify /me?fields=first_name,last_name,email

1
  • Flawless man! Thanks for that! Was really searching hard for this!
    – karan
    Sep 3, 2020 at 20:29
0

You should be able to use the username or email. You can get the email by doing this

 data.attributeMap.get('email');
4
  • Thanks PepeFloyd, but data.attributeMap.get('email') returns null also. Looping through all the key/values in data.attributeMap and it contains only 'id' and 'sfdc_networkid'.
    – Amul Shah
    Jan 12, 2016 at 23:10
  • Are you using the default auth provider config or did you create your own fb app?
    – PepeFloyd
    Jan 12, 2016 at 23:17
  • I've created by own fb app. Within auth providers settings I have Authorize Endpoint URL, Token Endpoint URL, User Info Endpoint URL, Default Scopes, Custom Error URL, Custom Logout URL all blank. I thought it could be Default Scopes, but if I enter a value in there (e.g. id or refresh_token full) I get an "We can’t log you in because of the following error. No_Oauth_Code: Exchange code was not returned" error whilst trying to login.
    – Amul Shah
    Jan 12, 2016 at 23:48
  • There must be something wrong with your app settings, it works fine with the default settings.
    – PepeFloyd
    Jan 13, 2016 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .