Retrieve Facebook User Name from Profile

I’ve spent the afternoon trying to retrieve basic user profile information from Facebook without success.

Going back to basics I’ve set up the sample project from Auth0 Angular SDK Quickstarts: Login

Logging in and displaying name(email) and nickname works fine, but I cannot display given_name or family_name. (I’ve also tried user_location and user_hometown)

In Auth0 dashboard under Social Connections, public_profile is ticked and cannot be unticked, but when I Try Connection profile/full name is not retrieved (nor location)

So it would seem to be a configuration issue within the Auth0 dashboard, rather than an application issue.

What should I try next?

Hi @CueToDo,

Welcome to the Auth0 Community!

I understand you are trying to retrieve the given_name and family_name properties from a Facebook connection user.

Here is what is returned if I use the default Facebook connection settings:

Can you share an example of what is returned in your request?

1 Like

Thanks Dan,

For some reason, when I “Try Connection” for Facebook, I’m getting back an auth0 response.

Hopefully a simple fix here somewhere … !



Would you please DM me your tenant name?

It looks like this is related to account linking. Checkout this doc that tells how to add the missing info:

Excellent, thanks Dan, adding the rule retrieves the extra data from the secondary identity.

1 Like

Glad we found a solution. Let me know if there is anything else!

Thanks Dan, there is actually - just a quick follow up about verifying what gets saved to the primary identity. Is it possible to do that from the dashboard?

As I said, I can save given_name and family_name and retrieve those values in my application …

but I’d really like to be able to access location. I’ve ticked this under the facebook connection and can view this under the Raw Json for myself as a user.


However, I’ve tried a variety of ways to add this to the primary identity so that I can see this in my application just like given_name.

Here’s my latest attempt: I’ve put identities in the outer loop and have changed the dot notation to array accessor with a string literal (despite warnings when editing the rule, the dot notation does not work). When I Iog in, I can see the value in the debug logs


How can I verify that this is saved? I can’t see given_name in the dashboard although it must be as this is returned to my application.

Here’s my rule:

function(user, context, callback) {
  const propertiesToComplete = ["given_name", "family_name"];

  // go over each property and try to get missing
  // information from secondary identities
  for(var identity of user.identities) {
    if (identity.provider === "facebook" && identity.profileData && identity.profileData.hometown){
      console.log("Hometown!", identity.profileData["hometown"]["name"]);
      user["hometown"] = identity.profileData["hometown"]["name"]; 
    for(var property of propertiesToComplete) {
      // if (!user[property]) {
        if (identity.profileData && identity.profileData[property]) {
          user[property] = identity.profileData[property];
      // }
  callback(null, user, context);

I seem to be so close, but missing a vital step.

Many thanks again for your help!


PS location AND hometown are in the Raw Json with identical values!


If you are trying to get location in the id token you can add it directly as a custom claim. This claim is specific to facebook identities.

Excellent, thanks again Dan, I appreciate your time - all sorted now!

It looks like there is a limitation on what can be attached to the user object, including location.

This simple test shows expected result in console, but property test is not sent to client application.

var propertyName=“test”;
user[propertyName] = “bajingo”;
console.log(“user[propertyName]”, propertyName, user[propertyName]);

As I already had a rule for a custom claim, I’ve now added location to that rule - and that can be retrieved from token when sent to my API.

Happy days!

Thanks again!

1 Like

Thanks for sharing your solution! Let us know if you run into anything else. :grinning_face_with_smiling_eyes:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.