How to add data (or query param) to redirect_uri?

Hi,

We want to figure out a way to send data to our web app after a user logs in. Basically we want to trigger something on our web app right after a user successfully logs in. One potential solution that we thought about was to add a query parameter to the redirect uri where the user gets sent after successful login, and then use that to determine that a user just logged in.

Ex.

loginWithRedirect({
            redirectUri: `http://localhost:3001/dashboard?justLoggedIn=true`,
        });

or

        <Auth0Provider
            domain={AUTH0_DOMAIN}
            clientId={AUTH0_CLIENT_ID}
            redirectUri="http://localhost:3001/dashboard?justLoggedIn=true"
            audience={AUTH0_API_AUDIENCE}>

We noticed that this was not possible because the query params gets removed once the user is redirected. Goes to http://localhost:3001/dashboard instead of http://localhost:3001/dashboard?name=auth.

Also looked into api.redirect.sendUserTo in auth0 action but we don’t want to temporary redirect the user and go back to auth0 to continue the workflow. Is there a suggested method for achieving this? or are we doing something wrong?

Hello @TheEWL welcome to the community!

What if you pass an object directly to loginWithRedirect as outlined in this post:

Alternatively, you could use the appState to achieve a similar result - As noted in the documentation:

If you need to send custom parameters to the Authorization Server, make sure to use the original parameter name.

https://auth0.github.io/auth0-spa-js/interfaces/redirectloginoptions.html#appstate

Hope this helps!

1 Like

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