I was a bit confused about how to get info from app_metadata
onto the user that is returned in useUser
/ getSession
. This is how.
Go to a User in Auth0
Add a piece of data to the app_metadata
section
1{ 2 "your_data": "this is my data" 3}
Create a Rule
Add this function
1function addYourData(user, context, callback) { 2 user.app_metadata = user.app_metadata || {} 3 context.idToken['https://pick.some.namespace/your_data'] = 4 user.app_metadata.your_data 5 callback(null, user, context) 6}
Now in your app when you useUser
or getSession
you will see this is my data
under the key https://pick.some.namespace/your_data
on the user object.
Please sign in to view and leave comments...