samples-blazor icon indicating copy to clipboard operation
samples-blazor copied to clipboard

signout error

Open yongkeecho opened this issue 1 year ago • 0 comments

Hi, I have a trouble to setup post_logout_redirect_uri. I tried all the combinations of PostLogoutRedirectUri and have no luck. Current value for the PostLogoutRedirectUri is /signout/callback.

"OktaDomain": "https://sso_url",
"ClientId": "0oabifez6gJD31bTr997",
"ClientSecret": "v6BiuCOXytcT7Q6_Yw-dgBeZTWz4xzlXSrusAXeofqHrzVpU4bV-Rq265Ve9MOZI",
"AuthorizationServerId": ""

In Program.cs, tried w/ and w/o PostLogoutRedirectUri.

    .AddOktaMvc(new OktaMvcOptions
    {
        OktaDomain = builder.Configuration.GetValue<string>("Okta:OktaDomain"),
        ClientId = builder.Configuration.GetValue<string>("Okta:ClientId"),
        ClientSecret = builder.Configuration.GetValue<string>("Okta:ClientSecret"),
        AuthorizationServerId = builder.Configuration.GetValue<string>("Okta:AuthorizationServerId"),
        //PostLogoutRedirectUri = new PathString(OktaDefaults.SignOutCallbackPath),
        Scope = builder.Configuration.GetValue<string[]>("Okta:Scopes")
    });

In AccountController.cs, tried w/ '~/' and /signout/callback.

        public IActionResult SignOut([FromQuery] string returnUrl)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return LocalRedirect(returnUrl ?? Url.Content("~/"));
            }

            return SignOut(
                //new AuthenticationProperties() { RedirectUri = OktaDefaults.SignOutCallbackPath },
                new AuthenticationProperties() { RedirectUri = Url.Content("~/") },
                [
                    OktaDefaults.MvcAuthenticationScheme,
                    CookieAuthenticationDefaults.AuthenticationScheme,
                ]);
        }

With all cases, the signout button redirects to "https://sso_url/oauth2/v1/logout?post_logout_redirect_uri=https://localhost:7180/signout/callback&...." with an error message of Error: The 'post_logout_redirect_uri' parameter must be a Logout redirect URI in the client app settings.

yongkeecho avatar Mar 11 '24 13:03 yongkeecho