Decoding state value once the user has been authenticated

I’m currently using the universal login provided by Auth0 and I’m trying to access the state value which would allow me to redirect the user to their previous login state or more specifically the URL they were visiting prior to being authenticated.

It’s currently stored by the universal login in a format like the following:

com.auth0.auth.{value}: "{"nonce": {value} ] ,"state": {value} }"

As mentioned in the docs here:
" You can also use the state parameter to encode an application state that will round-trip to the client application after the transaction completes. In this way, the application can put the user where they were before the authentication process happened. For more information, see Redirect Users With State Parameters."

The issue I’m currently encountering is that I’m not sure what the best way would be to decode the state provided by the universal login. It seems like others are encountering the same issues and have mentioned this in prior posts:

Any guidance on how to best approach this would be greatly appreciated!

Hi @felix.wong,

Welcome to the Auth0 Community Forum!

One of the topics you linked mentions getting state in Rules. Could you confirm that you are trying to get the state parameter you provided in a rule, or are you trying to get it in your application after successful authentication?

In addition, can you provide some more context on your implementation. Are you using Auth0.js, auth0-spa-js, or something else? Are you encoding state initially?

Let me know.


Hi Dan,

I figured it out, thanks so much!


Glad it was figured out!

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