How to pass/access optional parameters to custom actions

I have an spa where I am setting custom claims in onExecutePostLogin. I want to optionally pass parameters (possibly from loginWithRedirect?) from the client to add to these claims so I can then pick up from the token and use in my app. Can anyone help with this?

Hi @j.clopton,

Welcome to the Auth0 Community!

Unfortunately, there isn’t a way to pass additional query parameters in your login request for the Action to read them.

For now, you could append these attributes to the user’s user_metadata as a workaround. This way, you can add these to the access token as a custom claim.

Let me know if you have any questions.

Thanks,
Rueben

Thanks for the response. The problem I am having is I think I need the custom claims to be dynamic. I want the user to be able to decide one of the values on the claim before or during the login. Is that possible?

Hi @j.clopton,

Thanks for your reply.

You can have dynamic custom claims, especially if the user has decided on one of the values before the login process. After they have decided on a value, you should store it in the user’s user_metadata by using the Management API Update a user endpoint.

Then, when they log in, you can get the user_metadata and append them as custom claims to the token using a Post Login Action.

Another workaround would be redirecting your users during the login process to a separate page to ask them to select their preferred value. Then, when resuming the auth flow, send that information back and append that information to the access token. See Redirect with Actions.

Let me know how this goes for you.

Thanks,
Rueben

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