Hey there @thekoala, bravo!
Thanks a bunch for sharing this with the community
I’ll add some color to this by sharing the following doc which outlines how metadata works in user profiles:
In addition to the Management API, you can also access user metadata via the /user
info endpoint (need the user’s access token), as well as via custom claims in the user id and/or access token. For example, here’s an action that will add both user_metadata and app_metadata to the user’s id token which can be extracted by your app post login:
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://my-app.example.com';
if (event.authorization) {
api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
api.idToken.setCustomClaim(`${namespace}/app_metadata`, event.client.metadata);
}
};
Thanks again for your engagement with this, I’m sure it will be beneficial to other users
Cheers!