Hi, I’m trying to use Okta Auth JS on an Okta hosted site. My code works fine when running locally. But, when hosted by okta, I get a 404 for any routes other than ‘https://{myOktaDomain}’ set as the redirect uri.
After signInWithCredentials is run, routing to ‘https://{myOktaDomain}’ redirects the user to ‘https://oktadev.dignityhealthppe.org/app/UserHome’ instead of loading my app so I can parseFromUrl().
Are there any callback routes that will work in this case?
Log into your okta site, go to the okta admin, and select Settings->Customization. On the General tab, we are setting the Custom URL Domain. On the Custom Sign In tab, instead of using the default html with the okta sign-in widget, we have a script reference to load the js for our app.
So… when a user goes to our domain… they are really going to okta’s servers and running our app.
In that case, it is expected that https://{yourOktaDomain} is the only valid redirect_uri. The Auth JS library stores the OAuth parameters in a cookie before making the /authorize request. Since you are using PKCE flow, you will need to use parseFromUrl() to parse the authorization code and exchange it for tokens. It will try to load the OAuth parameters from the cookie to make the /token request.
If you want to use a different domain for the redirect_uri, then you will need to host a page on that domain and then use signInWithRedirect().
Since you are using PKCE flow, you will need to use parseFromUrl() to parse the authorization code and exchange it for tokens
Can you explain the steps here? After a successful call to signInWithCredentials, calling back to https://{yourOktaDomain} doesn’t work. Okta is redirecting the user to https://{yourOktaDomain}/app/UserHome instead of loading the app (so I can’t call parseFromUrl).
If I call parseFromUrl without doing a callback, then it fails with “Unable to parse a token from the url”.