Hi,
I have multiple applications in my Auth0 tenant and I need to include the email claim in the access token for some of them. What is the most clean and efficient way to do this?
I’m considering using multiple if statements in one action, like this:
Copy code
exports.onExecutePostLogin = async (event, api) => {
if (events.client.id == 'xxx') {
api.accessToken.setCustomClaim(`${xxx_url}/email`, event.user.email);
} else if (events.client.id == 'yyy') {
api.accessToken.setCustomClaim(`${yyy_url}/email`, event.user.email);
}
};
However, I’m not sure if this is the best approach. Can I fetch the app IDs from Auth0 instead of hardcoding them in the script?
Or should I use multiple actions and have one action per application?
Is there a better way to do this?
Thank you in advance for your help.