'OIDC Logging out issue , How to control the browser programatically/manually?

I’m using OIDC client in my Xamarin App(Code below) So when I make the call oidcClient.LogoutAsync browser opens, and while I’m awaiting the response back from the browser to the app if I need to minimise the app for some reason. The call then gets interrupted and the app stays on the browser, Never gives a response back, unless user manually closes the browser. Now I have no control over the browser from my app, Is there a way to avoid this. Maybe not open the browser altogether and logout silently. Please suggest a workaround.

private OidcClient InitializeAuthClient()
{
    var options = new OidcClientOptions
    {
        Authority = Config.AuthorityURL,
        ClientId = Config.ClientId,
        Scope = Config.Scope,
        RedirectUri = Config.RedirectUri,
        ClientSecret = Config.ClientSecret,
        PostLogoutRedirectUri = Config.RedirectUri,
        Browser = new WebAuthenticatorBrowser(),
    };
    return new OidcClient(options);
}
OidcClient oidcClient = InitializeAuthClient();
LogoutResult logoutResult = await oidcClient.LogoutAsync(new LogoutRequest 
{ BrowserDisplayMode = IdentityModel.OidcClient.Browser.DisplayMode.Hidden, IdTokenHint = authData.idToken });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source