I’m trying to work out how to get user meta data as part of the profile returned by /userinfo.
This article aludes to it being possible but IMO does a pretty poor job of explaining the steps.
It says:
You can also use the GET /userinfo endpoint to get a user’s user_metadata, however, you must first write a Rule to copy user_metadata properties to the ID token.
That last sentence could definitely do with some elaboration. In any case, I went to Rules, created a rule from the “Move user metadata attributes to profile root attributes” template. I saved it. But I still don’t get user meta returned in the profile.
The same article also says:
Use the Auth0 Dashboard to configure application metadata which contains key/value pairs. To learn more, read Configure Application Metadata.
…suggesting (or at least I inferred) that it’s possible to instruct the application to pull in user meta via the Dashboard > Applications area. But again there’s no elaboration here.
What’s the best way to pull in user meta to the profile response from /userinfo?
Thanks for this! That works. Am I right that this should expose the meta data to the user info endpoint, rather than include the user meta directly within the JWT? That latter point would be great, as it would mean I don’t have to make an API call to Auth0 at all, but perhaps that’s not the done thing and again suggests my ignorance of JWT general practice!
Right, thanks. Is it possible (and this is probably my JWT noobness talking) to get the user meta added directly to the JWT, so I don’t even have to make the call to /userinfo?
That’s exactly what the code referenced above does - It adds existing user/app metadata as custom claims to tokens. Therefore you can get this directly from the jwt itself:
Hmm, that’s not my experience currently. What the code you provided did do was make the user meta suddenly available within the response to /userinfo. The JWT itself does not contain any meta data, so far as I can see.
This produces a JWT which, when run through jwt.io, contains the below. Notice it doesn’t have the user meta in the payload, which is what I’m asking and I believe your previous reply said should be there.