Get user meta as part of session token

Hi @chris.alwin,

Welcome to the Auth0 Community and thank you for your post!

You are able to pass more information about a user such as user_metadata to your application by using Custom Claims in order to add more fields to the token. This can be achieved with a Post-Login Action, as mentioned here, in our documentation about metadata.

An example would be as mentioned below:

const namespace = 'https://my-app.example.com';
    api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);

You can also check this community post, which references this Knowledge Article about Adding custom claims to tokens.

Additionally you might also be interested in having a look over the Authorization Extension.

I hope this helped.
Best regards,
Remus

1 Like