When user clicks on login we are redirecting user to okta hosted widget with the redirect url as query parameter and now once user logs in we want to redirect them based on the query parameter redirect URL.
e.g. okta hosted widget is on xyz.com and we are accessing that like https://xyz.com/?redirectURL=abc.com now how can we redirect user to abc.com after login (Assume that callback functionality already implemented on redirect url).
With signInWithRedirect({ originalUri: ‘abc.com’}); we can redirect user to the url which is there as originalUri but we don’t want to use that library so finding some solution without using library.
I am understanding that you have a landing page where you redirect the user to the Okta hosted widget and then after authentication want them to land back at another URL. Is this correct?
I need some more information. Are you initiating a SAML or OIDC flow for the authentication?
Yes thats correct. For example if I will use oktaAuth.signInWithRedirect({ originalUri: ‘www.aaa.com’}) then it will go to aaa.com from okta hosted login but once I refresh that okta hosted page then after login it is opening okta dashboard. So I just wan to know is there any configuration available with okta admin console or can I add some javascript over there which can go back to particular url.
and yes its OIDC flow.
NOTE: Window.href will work but that is just redirecting but not making authorize call before that even on the callback url.
If you are using OIDC, that makes it easier, you don’t need anything outside of the protocol. The redirect_url parameter in the query string for OIDC specifies where the user should land after a successful authentication. The URL has to be registered with the Okta application integration, because it won’t send the user to some place it isn’t supposed to. You can register as many landing pages as you want.
As an instructor for Okta I get similar questions all the time, and “how can I do this without the SDK?”. To answer that I built an example application that specifically does NOT use the SDK for this, designed to work against either Okta or Auth0. It may help you: https://gitbhub.com/jmussman/pirates