# Auth0 returns a stale userInfo

**URL:** <https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030>\
**Category:** Get Help\
**Created:** [July 11, 2018, 8:19am UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030 "2018-07-11T08:19:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![georgii.rychko](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@georgii.rychko](https://community.auth0.com/u/georgii.rychko)\
**Post date:** [July 11, 2018, 8:19am UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/1 "2018-07-11T08:19:14Z")

</div>

This issue is very similar to

> [@Check if email\_verified without signing in again](http://community.auth0.com/t/check-if-email-verified-without-signing-in-again/7014):
>
> I’m currently using the v8 version of auth0.js I’m successfully able to find out if the user’s email is verified with this call function getUserInfo() { var deferred = $q.defer(); accessToken = localStorage.getItem('accessToken'); webAuth.client.userInfo(accessToken, function(err, userInfo) { if (err) { deferred.reject('Can not get user info'); } else { userInfo = userInfo; deferred.resolve(userInfo); } }); With this inf…

and

> [@Calling user info endpoint returns stale information for email verified attribute](http://community.auth0.com/t/calling-user-info-endpoint-returns-stale-information-for-email-verified-attribute/6699):
>
> I’m using Auth0.js to call signupAndAuthorize, effectively storing an access\_token in localStorage and calling the HTTP API directly (not through Auth0.js) at /userinfo to get the email\_verified value for the user. I keep doing that every time the app starts. When I tried verifying the email though, I see it as true on the Raw JSON part of the Dashboard, but the calls to /userinfo keep returning email\_verified=false! This happens until I login again, then I get it as true. Why?

Here is my use case:

1. A user changes its profile
2. Changes get sent to Auth0 using [Management API Reference - Auth0 Docs](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.

---

<div class="post-metadata">

**Author:** ![Carlos\_Mostek](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/carlos_mostek/32/8140_2.png) [@Carlos\_Mostek](https://community.auth0.com/u/Carlos_Mostek)\
**Post date:** [July 11, 2018, 5:15pm UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/2 "2018-07-11T17:15:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Carlos\_Mostek](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/carlos_mostek/32/8140_2.png) [@Carlos\_Mostek](https://community.auth0.com/u/Carlos_Mostek)\
**Post date:** [July 11, 2018, 9:04pm UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/3 "2018-07-11T21:04:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![georgii.rychko](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@georgii.rychko](https://community.auth0.com/u/georgii.rychko)\
**Post date:** [July 12, 2018, 7:36am UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/4 "2018-07-12T07:36:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![georgii.rychko](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@georgii.rychko](https://community.auth0.com/u/georgii.rychko)\
**Post date:** [July 12, 2018, 7:37am UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/5 "2018-07-12T07:37:23Z")

</div>

Thanks for the Management API advice!

---

<div class="post-metadata">

**Author:** ![andrej.developer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrej.developer/32/10294_2.png) [@andrej.developer](https://community.auth0.com/u/andrej.developer)\
**Post date:** [January 7, 2019, 6:45am UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/6 "2019-01-07T06:45:06Z")

</div>

What is then the “intention” purpose of this endpoint? Why would anyone call this endpoint, if not to get current user profile? (at the time of authentication we can get user information in claims don’t need another call)

- If this endpoint returns “information about last authentication” it should not be called “userinfo” (misleading name)
- None of this “intent” or use is even mentioned in documentation that states:

> to obtain the user’s profile

- suggestion to get the actual user profile through 2 hoops of API/Management API instead of single call to the source of information is cumbersome at best.

---

<div class="post-metadata">

**Author:** ![Carlos\_Mostek](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/carlos_mostek/32/8140_2.png) [@Carlos\_Mostek](https://community.auth0.com/u/Carlos_Mostek)\
**Post date:** [January 8, 2019, 3:56pm UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/7 "2019-01-08T15:56:23Z")

</div>

I hear what you are saying :). /userinfo does seem like a pointless endpoint because it generally is. There are few cases where it is necessary. It exists because it is part of the OIDC specification, but the fact is that 99% of the time it is better to just grab the information from claims inside the ID token and save yourself an extra API call entirely.

The Auth0 behavior for this endpoint exists because you can set custom claims that are defined when you run rules. Rules only run as part of generating new tokens. Since the information from /userinfo must match the information in the ID token, the only way to generate those custom values would be to run rules again. So, if you want to update /userinfo, you need to call /authorize again to refresh the authentication session.

All that being said, you also make a great point about this needing clarification on our docs page. I’ll send this over to the docs team.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 11, 2019, 5:06pm UTC](https://community.auth0.com/t/auth0-returns-a-stale-userinfo/13030/8 "2019-02-11T17:06:18Z")

</div>

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