Missing Custom Claims in Renewed Tokens Using checkSession

I implemented a custom action that adds custom claims to both the ID token and access token. These claims are added using both the namespace and non-namespace formats. Additionally, I am using the onContinuePostLogin trigger in my action to manage these claims.

When a user logs in for the first time, I can see the custom claims in the tokens as expected. However, in my React application, when renewing tokens using the auth0.checkSession function, the newly generated tokens do not include the previously added custom claims.

Could you please help me understand why the custom claims are missing in the renewed tokens and guide me on how to ensure the claims are included in all token renewals?

Thank you for your assistance!g for your answer.

api.idToken.setCustomClaim(ns, newOrgArray);
api.accessToken.setCustomClaim(ns, newOrgArray);
api.idToken.setCustomClaim(“employee_id”, newOrgArray);
api.accessToken.setCustomClaim(“employee_id”, newOrgArray);

Hi @hudson,

Welcome to the Auth0 by Okta Community!

You can debug your action script logs to verify the behavior using Real-time Webtask Logs Extension. We recommend also using console.log() statements to debug.

We also strongly recommend using namespace custom claims. This is typically a best practice because, in the case of collisions, the transaction won’t fail, but your custom claim won’t be added to your tokens, which could be your issue. There is some documentation linked that can be helpful.

Hope this helps!

Found the solution myself:
I used the query.promp to check if this is a silent auth then apply my logic and pass the additional parameter via checkSession method to handle my rules inside the action:

 if (event.request.query.prompt === 'none') {
      const currentOrgId = Number(event.request.query?.additional__parameters?.org_id) || 0
      const currentStage = event.request.query?.additional__parameters?.stage === 'dev' ? 'test' : event.request.query?.additional__parameters?.stage;

...
1 Like