Logout Redirect URI not working
Hello,
In your Okta application under the general tab do you have an entry in Sign-out redirect URIs
exactly how the browser is sending it?
yes I do
https://localhost:5052/home/index
I think I have a similar (maybe the same) problem. My application is a SPA, I basically followed this tutorial ( Embedded Okta Sign-In Widget fundamentals).
I also have the Sign-out redirect URIs
to the address of my page, http://localhost:3000.
I have my logout function written exactly the same as in the tutorial
function logout() {
oktaSignIn.authClient.signOut();
location.reload();
}
I noticed that the tokens and other information are stored in the localStorage… so I also tried to add after oktaSignIn.authClient.signOut()
, localStorage.clear()
. It indeed clears the localStorage, but magically it re-logs after it page refreshes. Does any one know what is going on?
I found a working solution, but I posted it here, since I don’t know if it is the best one.
@ amanthakur Are you able to share a .har file of an attempted logout. Of not because you do not want to share Org details if you could open a support case and attach the .har file there.
@ adrianopinaffo You could do something like the below (assuming OIE),
oktaSignIn.authClient.signOut({
clearTokensBeforeRedirect: true,
postLogoutRedirectUri: 'http://localhost:8080/myApp.html'
});
return new SignOutResult(
new
{
OktaDefaults.MvcAuthenticationScheme,
CookieAuthenticationDefaults.AuthenticationScheme
});
This is what I have in my signout code.
[HttpPost]
public IActionResult SignOut()
{
return new SignOutResult(
new
{
OktaDefaults.MvcAuthenticationScheme,
CookieAuthenticationDefaults.AuthenticationScheme
}
, new AuthenticationProperties { RedirectUri = “/home/index” });
}
I am working with an .net core example posted on OKTA example github.
I have not issues with Sign in. Its the signout only.
This looks correct.
Can you explain what you see if you open dev console in your browser and watch the network tab during a logout.
Are you redirecting to Okta, logging out, then redirecting back to your application?
Can attach a .har file of your logout sequence?
har file header, has a uri pointing to Acccount/SignOut.
I don’t have that in my code anywhere.
The /logout call to your Okta Org is returning a 400, please supply the entire URL of the call.
I have the entire URI.
That is the /signout for the application, I am looking for the full Okta /logout URL, This is what the /signout redirects to,
https://{domain}okta.com/oauth2/default/v1/logout?post_logout_redirect_uri=https%.....
If you can’t supply this the response to the /logout (where you receive a 400) should have an http-header named x-okta-request-id
. If you can provide that value it might help us.