Hi Auth0 community! I recently ran into an issue with updating user app_metadata
from the
fetchUserProfile
script. I had a custom social connection which was storing additional data about users in app_metadata
. This approach was working well until I added a new rule that was also performing some operation on app_metadata
by calling the auth0.users.updateAppMetadata
method. As soon as that method was called from the rule, my fetchUserProfile
script was no longer able to perform updates on app_metadata
. I found this note in docs that itâs not recommended to populate app_metadata
from fetchUserProfile
. It doesnât elaborate why, but I assume itâs to avoid issues such as the one I encountered.
I searched for potential solution to this issue and found PATCH user.app_metadata isn't behaving as documented which seemed to be related to issue I was observing because auth0.users.updateAppMetadata
method is performing PATCH
operation under the hood. The solution from this thread suggested storing user data in custom property. It worked well at first glance, as I was seeing updates being reflected in Auth0 UI (new property showed up in Identity Provider Attributes
section). However, despite that change being reflected in UI my rules were still getting outdated version of this custom property. Similarly to app_metadata
property as soon as auth0.users.updateAppMetadata
method was called that property was somehow âcachedâ in rules and no updates from fetchUserProfile
script were picked up from rules.
Do you have any advice on how to properly store (and be able to update) custom user profile data via fetchUserProfile
script?