Auth0 Home Blog Docs

Unable to fetch user info through userprofile API


#1

Hello Team,
After adding open ID and profile, I am still not getting the user profile on making an ajax request at /userInfo . The end point only returns ‘sub’ while it should actually return the complete user profile including the name and details for that particular user. Can you help me in this?

Thank you


#2

I believe by default the /userinfo endpoint will only have standard claims (attributes) defined in the OIDC specification and more specifically only the ones that correspond to the requested scope. If we want to receive back additional details, we will need to add custom claims that are added via a Rule. More information about this can be found in this document.

What specific details for the particular user were you expecting to receive?


#3

This is what i am seeing in userprofile endpoint. Why i am not seeing name of user as per Auth0 documentation?


#5

@kim.noel Any updates on my issue?


#6

I apologize for the delay I did not spot your response. What scopes are you specifying in your authorize request?


#7

@kim.noel we tried using 2 scopes openid and profile but it didnt worked.


#8

did you pay the two scopes openid profile in the scope parameter in the initial authentication request (when you get your access token) ? Can you check the JWT you receive when you authenticate? I believe the userInfo will only return the sub of the user for scope openid . If you want the user_metadata you’ll need to add it through a custom claim to the id token.


#9

@kim.noel Thanks for your reply. Can you guide me how to add through a custom claim to the id token? Also what all information we will receive in user_metadata?


#10

a sample would look like this:

function (user, context, callback) {
  const namespace = 'https://myapp.example.com/'; // note you cannot use auth0.com, webtask.io or  webtask.run as a namespace identifier
  context.idToken[namespace + 'favorite_color'] = user.favorite_color;
  context.idToken[namespace + 'preferred_contact'] = user.user_metadata.preferred_contact;
  callback(null, user, context);
}

The user metadata is associated with the user and will depend on what you set for the user.


#11

@kim.noel Thanks for detailed explanation. When i was reading standard claims i found sub and name are both part or OIDC but we only get sub and not name. Here is the link to standard claims : https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims

Is there anything wrong in our auth0 config?


#12

@kim.noel Any update on my above question? I would appreciate if you could help me in getting detailed explanation of my above question which might help in solving the issue?


#13

@kim.noel I am waiting for any update on my question?