Hi, i’m using an Action with api.idToken.setCustomClaim to enrich my token with some metadata but in the token received my value is nowhere to be found.
I try setting the key with my namespace or without and it’s the same result.
Same thing in a rule that work fine for a long time and since monday nothing’s working.
Is this a problem from Auth0 that could be fixed quickly ?
I just altered the code a bit to exclude the namespace, but the following worked for me as expected:
exports.onExecutePostLogin = async (event, api) => {
if (event.user.app_metadata.licenceKey)
{
console.log(`made it here, licenceKey is: ${event.user.app_metadata.licenceKey}`)
api.idToken.setCustomClaim('licenceKey', event.user.app_metadata.licenceKey);
}
else
{
api.access.deny("No LicenceKey attached to this user.");
}
};
Sounds silly, but have you made sure the Action is added/enabled on the login flow (Actions → Flows in your dashboard)? I would also check to make sure the licenceKey property in app_metadata is correct.
i tried with and without the namespace already and same result, it’s in my login flow and is enabled.
licenceKey property is correct, i was using a rule that does the same thing but directly set the value in the object, it worked for a long time but since monday it stopped working.
Does the console.log show up in the Action logging? If you go to Monitoring → Logs in your dashboard and then find the successful login event - You should see an “Action Details” section where this would be printed.
I’m not able to add a customClaim successfully, i tried with juste addind a test claim like (“TestClaim”, “Test Value”) but nothing in the final token.
Here’s my scopes: ‘openid’, ‘email’, ‘profile’, ‘offline_access’.
And since it doesn’t add it to the token i don’t see it in my userInfo.
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!