Actions not firing

Hello, I have been trying to add an action to my login flow and have been having some issues.
I have the below action in my login flow:


exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'test-1865945745686';
  if (event.authorization) {
    console.log('test!!')
    console.log(event.authorization.roles)
    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
  }
}

When I use the ‘Try your Login box’ option everything works as expected. However, when I try and do it through my React application the action does not fire, it gets no logs and the roles claim is not on my token. Any help is appreciated.

Hi @KINGKENNA ,

Your code snippet is correct, I took it to my Auth0 tenant’s Actions and the access token issued has the "test-1865945745686/roles": [], claim within a payload.

In this case very likely is that your app is not fully configured with Auth0. Can you please check the doc you’ve used to set up your app with Auth0 to see if you are missing some something?

On your app code base side you need the Client ID (registered in Auth0) of your app, the Auth0 domain and the audience (API identifier) for which you want Auth0 to issue the access token:

Another thing to check if is the aurhorization happened at all or maybe failed? You can verify it on the Monitoring tab in the Auth0 tenant.

Please let us know how it goes!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.