I added a ‘Login with Okta’ button on my SPA using oktaAuth.signInWithRedirect, but it didn’t redirect back to the redirectUri after I logged in on the Okta login page.
Here’s the steps:
I clicked the ‘Login with Okta’ button, and the page redirected to the Okta login page.
I clicked ‘Sign in with Google’ to log in.
After logging in using my Google account, the page redirected back to the Okta login page.
Then the page redirected to the Okta dev dashboard, but not to the redirectUri.
I tried oktaAuth.signInWithRedirect(originalUri: ''), but it didn’t work.
Any suggestions would be greatly appreciated!
Are you using an Okta Classic org, or an Okta Identity Engine org?
What you’re describing sounds similar to a limitation in Okta Classic that, in a self-hosted widget, Federated Users (e.g. users from an external IdP like Google) will only be logged into Okta, but the /authorize request is not made (this is mentioned in the widget readme here).
I should note that that solution still requires your application to issue an /authorize request itself. Setting the fromURI as in that example only ensures the user isn’t redirected to the dashboard, but the OAuth flow will not be made until your application kicks it off
Thanks for your reply!!!
I’m new to Okta development, could you talk more about how to make /authorize request in this case? I’ve gone through the post you shared, but the solution is still unclear to me, does it means I should replace window.location.href = " https://{ oktaDomain}/sso/idps/{googleIdpId}?fromURI=" +encodeURI(redirectUrl); with await oktaAuth.signInWithRedirect()?
By the way, I use @okta/okta-auth-js but not Okta-Sign-In Widget.