Hey all,
Trying to add some custom metadata to my access tokens using Actions and it doesn’t seem to be working. Running the action seems ok, I am able to add custom claims to the ID token too. Here is my Action:
exports.onExecutePostLogin = async (event, api) => {
api.accessToken.setCustomClaim("yahadsf", "working")
api.idToken.setCustomClaim("idyah", "yah")
// if (event.authorization) {
// api.accessToken.setCustomClaim("myapp_id", event.user.user_metadata.myapp_id);
// }
};
Appreciate the help, thanks!
Hi @bmorrisondev
Welcome to the Auth0 Community, it’s great to have you here.
You may need to add a namespace, simplest implementation might look like this:
exports.onExecutePostLogin = async (event, api) => {
api.accessToken.setCustomClaim("https://mynamespace/fave-colour", "Blue");
};
You can see more details here https://auth0.com/docs/get-started/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token
Warm regards.
1 Like
Hey there!
As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!
Learn more here!