How to get user profile data

Hi, im making my spa angular app with this tutorial: https://auth0.com/docs/quickstart/spa/angular2/01-login#showing-profile-information
the question is, how to get rest of the users profile data i.e. login count.

Hi @tmtm, welcome to the Auth0 Community!

If I understand your question correctly, the best way to enrich the information that comes back with the ID token is by creating a Rule through the Auth0 Dashboard.

From the Dashboard, click Rules on the left. Then click Create Rule. The most similar template to what you’re wanting is “Add country to the user profile,” but feel free to explore the others. The piece of data that you’re looking for is in the context object and is context.stats.loginsCount. You can create a custom property on your ID token (context.idToken['loginsCount'], for example) to be able to access this data in your app once you retrieve the user profile.

Here are the docs about Rules to learn more.

Hope that helps!

Cheers,
Sam Julien

1 Like

Hi @sam.julien, thank you for your response. I don’t want to enrich profile with additional data, i just want to get the attributes which i can see in Users Profile in dashboard (Identity Provider Attributes), the object which is returned after sucessfull login in tutorial i mentioned early, has few properties i.e.:

  1. email: “tmuxxxxxxxxxx”
  2. email_verified: false
  3. name: “tmuxxxxxxxxxx”
  4. nickname: “tmuxxxxx”
  5. picture: “https://s.gravatar.com/avatar/xxxxxxxxxxx”
  6. sub: “auth0|xxxxxxxxxxxxxxx”
  7. updated_at: “2019-07-27T11:29:30.413Z”
    But when i log into dashboard i see more properties for this user:
  • blocked_for
  • last_ip
  • last_login
  • logins_count

And this is what im trying to get :). Maybe i need to add some options to getUser() method?

Hi again @tmtm,

This can be a bit confusing since you’re seeing those attributes on the User page, but the seven attributes you mentioned are part of the OIDC standard claims, which is why they come back on the ID token. Any attributes beyond that have to be retrieved using a Rule.

Does that make sense?

Cheers,
Sam Julien

1 Like

Hi @sam.julien,

Thank you for explaning, so if i understand these additional properties exist in user database, but i need to use rule to get them?

Some of the data is in the User object and some of it is in the Context object, but you can tap into both of those in Rules and assemble what you need to return outside of the standard attributes.

1 Like