serpa
January 4, 2023, 9:49am
1
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.
tyf
January 6, 2023, 12:01am
3
Hi there @serpa welcome back!
serpa:
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?
I’m not sure I can recommend a best approach here but adding all related logic to 1 action seems like it should do the trick!
You can certainly get all applications/clients using the Management API from within your action . If you go this route, you may also want to look into caching Management API tokens:
Problem statement: How do I cache a Management API access token(s) using the Node Management Client and Actions caching functionality?
Auth0 recently announced the ability to cache tokens within our extensibility solution, Actions. This has been a much requested feature that we are excited to have finally released. As many users utilize the Node Management Client to interact with the Management API by way of Actions, the question of how to incorporate the new caching functionality has arisen.
S…
Hope this helps!
system
Closed
March 9, 2023, 1:23am
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.