How to get fromuri/returnuri from the callback method after login


My main requirement is when user gives un authenticated url (https:mydoimaincom/user/create) it should navigate to login and after login it should go back to the original url (https:mydoimaincom/user/create) not to the home page.

I am calling authorize api to validate and that is working fine and callback method is also working fine.
https://{domain}/oauth2/default/v1/authorize?client_id={clientID}&response_type=code&scope=openid email profile&redirect_uri={redirectUri}&state={state}

Now I would like to send and get return uri or original uri or from uri to the callback method after successful authorizaiton. So that I can redirect to the original uri…

callback method:
public async Task OktaLogin(string code, string state)
right now I am receiving only code and state. Is there any option to receive orignal uri? if so or not please suggest a way to handle this situation. I have searched a lot but couldn’t get the right one.

Please help me on this.


Our SDKs will handle this with something like cookies. For example: User hits a route called /user, which is a protected route, application stores that this is the route the user was on in a cookie, user is sent to authenticate, and then are sent back to the app’s callback route, and once the tokens are fetched and stored, user is sent back to /user based on that cookie.

@andrea any doco on that?

At a client we ended up rolling our own destination persistence mechanism (persisting the original destination before redirecting to Okta for Auth) but they weren’t using the Okta React SDK.