How to get user_metadata and app_metadata after login, using PHP SDK?

I have managed to setup a registration–>login–>logout flow using the PHP SDK. However I can’t managed to figure out on how to get a logged in users user_metadata and app_metadata.

I can show some userinfo via $userInfo = $auth0->getUser(); this returns an array of the bare minimum user data like email, verified, last_updated etc. But how do I get the additional data that is present on the raw json object if I inspect the user in the auth0 dashboard, mainly the user_metadata and app_metadata?

You can use a Rule to add the metadata as custom claim to the user info. Code in the rule would be something like this:

context.idToken['http://somenamespace/user_metadata'] = user.user_metadata;

Also see

1 Like

Ahh it was actually that simple, thanks a lot :slight_smile:

1 Like

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