How get app_metada react SDK

Hi There,
I made a quickstart SPA using the react SDK instruction. - Auth0 React SDK Quickstarts: Login
For users in users&roles - users - Metadata - app_metadata created metadata.

{
“roles”: [
“operator”
]
}

I see app_metadata on the Raw JSON page.
Получаю данные пользователя в приложении реакт:

import { useAuth0 } from ‘…/…/react-auth0-spa’
const { user } = useAuth0()
user.app_metadata - undefined

But there is no app_metadata parameter in user.
How can I get app_metadata?

Hi @ddolgov ,

I believe the user object is based on what is returned in the ID token, but app_metadata isn’t a standard OIDC claim.

To get around this, you can add the app_metadata as a custom claim and it should be available in the user object the next time you fetch a token. Please see here for some more detail on adding custom claims to tokens:

1 Like

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