Hi,
I successfully deployed MAUI application to my devices and authenticating with Auth0 works on both IOS/Android platforms. I was wondering what is the best way to retrieve additional sections fromt the user, such as app_metadata where I am adding the roles for the user.
I am a C# developer and any help on this topicwould be much appreciated, thanks!
The most effective way is probably to add the metadata to tokens and go about it that way - You need to add the metadata as a custom claim(s) using an action:
This is the user_metadata section on the Auth0 user:
{
“roles”: “admin”
}
This is the custom function I have added to the login process:
/**
Handler that will be called during the execution of a PostLogin flow.
@param {Event} event - Details about the user and the context in which they are logging in.
@param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
const namespace = ‘https://dev-70vjf83lo03hdc1r.uk.auth0.com’;
const { roles } = event.user.user_metadata;
// Adds your data to the id token
if (event.authorization) {
// Set claims
api.idToken.setCustomClaim(${namespace}/roles, roles);
}
};
I have no idea what else I can try orwhere I am mistaken, any help would be much appreciated!