Sign-Out of Angular App with Redirect using Okta Hosted Sign-In Widget

I am trying to utilize the Okta Auth JS sdk to sign the users out of my angular application. I want to be able to redirect the user to a page in my app after they are signed out instead of driving them to the Okta Hosted Sign-In Widget. Is there a way to do this?

I have tried just calling oktaAuth.signOut({postRedirectUri: '/sign-out'}) but that does not sign them out of the app.

I have tried using oktaAuth.tokenManager.clear() but that always drives them back to the Okta Hosted Sign-In Widget.

Not sure what I am missing, so any guidance would be appreciated!

This should be “postLogoutRedirectUri”, not “postRedirectUri”, and must be an absolute url:

okta.signOut({ postLogoutRedirectUri: window.location.orign + '/goodbye' });

Sorry, I wrote the property name by memory and mistyped it. I didn’t realize it needed to be an absolute url.

Also, I am assuming the postLogoutRedirectUri overrides the logoutUrl that is passed in as an option into OktaAuth or are they not the same thing?

Thank you!

The logoutUrl passed would be the logout url found at your authorization server’s well-known endpoint. When you call signOut(), the sdk makes a call to that endpoint where it passes in the id_token_hint and the post_logout_redirect_uri params.

So it doesn’t override it, but it sets that parameter to the url you specify. The value you set for your postLogoutRedirectUri has to match the Sign-out redirect URIs that are set on the client in Okta or it’ll throw a 400 Bad Request:

Happy to help :slight_smile:

1 Like

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