Auth0 Home Blog Docs

Cached user is not refreshed with custom database



Hi awesome Auth0 and community,

I have a setup where I use custom database (and scripts) to authenticate and return a user profile.

In the Custom Database dashboard when i “try” my scripts, the user is returned with updated values.

When I search for the user in Auth0, these values (e.g. in app_metadata) are not updated. I am aware that Auth0 caches the user. But it states in the documentation that the user will be refreshed each time the user authenticates. (

The only way I can force an update through is by deleting the user account - which then will be regenerated upon next authentication and the values are updates. I’d rather not use this approach since it’s will remove stats an etc.

Am I missing something?

Kind regards,



I am still facing this issue - any news/suggestions?


For future searches:
I managed to resolve my issue and get updated values by returning the custom fields I need as a part of a user_profile property in the normalized user object parameter of the callback function (of the login script in my custom database connection).


return callback(null, { 
    userId: userId, 
    // ... omitted
    user_profile: { 
        foo: "bar",
        custom: "field" 

Then I add the custom values I need as a part of the idToken in the form of a Rule.

function (user, context, callback) {
    var namespace = '';
    if (context.idToken) {
        context.idToken[namespace + 'foo'] =;
        context.idToken[namespace + 'custom'] = user.user_profile.custom;
   callback(null, user, context);

Now when the user gets updated and logs back in, the properties in the user_profile gets updated every time.

However I’d like to point out that this is not as clear as it could be in the docs - atleast for me.
Reading about user profiles and custom database scripts at makes it sound like the app_metadata property can be used to store user related values.
… and the fact I couldn’t find any articles about the user_profile field.
But now after figuring how to solve my problem and how to handle user profile claims in the OIDC way as described in it all makes sense again.

It doesn’t really explain why app_metadata doesn’t update on subsequent logins - now it’s just a mystery.

Big shoutout to who got me in the right direction! Thanks for the help and updating your issue with how you resolved it (User profile not updated when user login (custom connection OAuth2))!


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