# Access State Param used in Redirect before redirecting

**URL:** <https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [January 23, 2025, 8:47pm UTC](https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017 "2025-01-23T20:47:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdrew1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jdrew1/32/61813_2.png) [@jdrew1](https://community.auth0.com/u/jdrew1)\
**Post date:** [January 23, 2025, 8:47pm UTC](https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017/1 "2025-01-23T20:47:50Z")

</div>

In my post-login action, I need to redirect users to a portal that updates some info. The portal takes a token which itself has a redirect for its callback. I need to be able to include the State param in the redirect url in the token, but I’m not sure how to access it in the Post Login Action.

EG 1 User logs in via universal login  
2 Post login script redirects user to 3rd Party Portal (using sendUserTo(\<3rdPartyUrl\>)). In my case, the 3rdParyUrl has a custom token that includes a callback url (It will be like: [https://myAuth0Site.com/continue?state=[state]](https://myauth0site.com/continue?state=%5Bstate%5D))  
3 User is redirected back to auth0 where action continues after verifying state

In step 2, how do I determine the state param that will be used by AuthO?

I cannot tell from the docs how to access that value or if that’s even possible

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [January 23, 2025, 9:27pm UTC](https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017/3 "2025-01-23T21:27:52Z")

</div>

Hi @jdrew1,

The `state` parameter you need to use to pass back to the `/continue` endpoint should match the same state used in your initial login request (`/authorize`).

When you call the `api.redirect.sendUserTo` method, you do not need to append the `state` value yourself because Auth0 will redirect the user to the URL you specified and pass the `state` parameter in that URL. (Reference: [Redirect with Actions](https://auth0.com/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/redirect-with-actions#:~:text=After%20the%20Action%20has%20finished%20executing%2C%20Auth0%20redirects%20the%20user%20to%20the%20URL%20specified%20in%20the%C2%A0api.redirect.sendUserTo()%C2%A0function.%20Auth0%20also%20passes%20a%C2%A0state%C2%A0parameter%20in%20that%20URL.%20For%20example%3A%C2%A0))

Afterward, you can send the user back to the `/continue` endpoint with the `state` parameter to resume the authentication transaction.

I hope this helps!

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![jdrew1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jdrew1/32/61813_2.png) [@jdrew1](https://community.auth0.com/u/jdrew1)\
**Post date:** [January 23, 2025, 10:07pm UTC](https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017/4 "2025-01-23T22:07:15Z")

</div>

Thanks, Rueben. I get what you’re saying, but the problem is that the 3rd party service will send the user to whatever callback URL I include in their token. So when you say:  
" Afterward, you can send the user back to the `/continue` endpoint with the `state` parameter to resume the authentication transaction." To send the user back, I need to include the callback url in the original token (I don’t have control of this third party server). So I need to embed the /continue endpoint in the token I’m sending to that server as the callbak url with the state param attached to it. Does that make sense?

---

<div class="post-metadata">

**Author:** ![jdrew1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jdrew1/32/61813_2.png) [@jdrew1](https://community.auth0.com/u/jdrew1)\
**Post date:** [January 23, 2025, 10:09pm UTC](https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017/5 "2025-01-23T22:09:00Z")

</div>

I’m currently toying with a proxy service (that I would have full control over) that would handle the redirect, returning to /continue with the state param. Is that my only option, or is there some way to access the state param from the action?

---

<div class="post-metadata">

**Author:** ![jdrew1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jdrew1/32/61813_2.png) [@jdrew1](https://community.auth0.com/u/jdrew1)\
**Post date:** [January 23, 2025, 11:35pm UTC](https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017/6 "2025-01-23T23:35:31Z")

</div>

Also, the state param passed from the service provider to the /Authorize endpoint is not the same as the state param that Auth0 attaches to the redirect url in a post-login action. It does eventually go back to the SP, in the final redirect after the post - login action completes, but the state param between SendUserTo() and /continue is a auth0 generated thing.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 6, 2025, 11:35pm UTC](https://community.auth0.com/t/access-state-param-used-in-redirect-before-redirecting/170017/7 "2025-02-06T23:35:47Z")

</div>

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