Auth0 Home Blog Docs

Auth0 returns a stale userInfo


#1

This issue is very similar to

and

Here is my use case:

  1. A user changes its profile
  2. Changes get sent to Auth0 using https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
  3. Then I reload my SPA
  4. SPA fetches data from the userInfo endpoint using token stored in local storage
  5. userInfo response contains stale data (the one that existed before the user was patched)
  6. Though when I go to Users section (in Auth0 admin panel) - the user I’ve patched has the latest changes.

In my case, the userInfo object has a metadata section which contains user’s lastname and firstname. And this is the section which has a stale data when accessing it using the userInfo endpoint.


#2

This is intentional behavior. The /userinfo endpoint contains information about the last authentication. You will not get new information until the next authentication request.


#3

One other thing you can do is use the Management API to get new user information. To do this you would have to proxy the call to the management API through your own API so that you can use client credentials to get a Management API token to get the data about the user that is the latest.


#4

Now it is clear. I guess it would be very convenient to say about this behavior explicitly in the docs.


#5

Thanks for the Management API advice!