uwpwin-universal-appopenid-connectoidc-clientidentitymodel

Logging out from IdentityServer does not close the webview popup


I have used IdentityModel.OidcClient with a UWP app and connected to Azure AD. Login webview opens and automatically closes but the logout popup does not automatically close.

My implementation is based on this. When logout happens the final function call goes here but until the popup closes manually, execution hangs inside this AuthenticateAsync function call.

if (string.Equals(options.EndUrl, WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri, StringComparison.Ordinal))
            {
                wabResult = await WebAuthenticationBroker.AuthenticateAsync(
                    wabOptions, new Uri(options.StartUrl));
                //Execution returns here, once the popup closes manually.
            }

Logout happens correctly but the popup remains. Post logout URL was also configured correctly. enter image description here


Solution

  • found the answer. You need to setup the LogoutRequest object and set the IdentityToken from the LoginResult object (Comes from the response of LoginAsync function) and send it with the LogoutAsync function.

    var logoutRequest = new LogoutRequest
    {
         IdTokenHint = _result.IdentityToken,
         BrowserDisplayMode = DisplayMode.Visible
    };
    await oidcClient.LogoutAsync(logoutRequest);