【问题标题】:Xamarin Android CookieManager unable to remove cookiesXamarin Android CookieManager 无法删除 cookie
【发布时间】:2019-11-19 00:30:28
【问题描述】:

Xamarin Android CookieManager.hasCookies() 返回 false,表示没有 cookie。

public static async Task<string> SignOut(){

    IEnumerable<IAccount> accounts = await App.IdentityClientApp.GetAccountsAsync();

    foreach (IAccount account in accounts)
    {
        await App.IdentityClientApp.RemoveAsync(account);
    }

    DependencyService.Get<ILogoutHelper>().LogoutSSO();

    graphClient = null;
    TokenForUser = null;

    return "";
}

public class LogoutHelper : ILogoutHelper
{
    public void LogoutSSO()
    {
        CookieManager.Instance.RemoveAllCookies(null);
        CookieManager.Instance.RemoveAllCookie();
        CookieManager.Instance.RemoveSessionCookie();
        CookieManager.Instance.Flush();
        Device.BeginInvokeOnMainThread(() => new Android.Webkit.WebView(null).ClearCache(true));

    }
}

我想清除操作系统浏览器上的 cookie,以便不缓存 MSAL 登录凭据。

【问题讨论】:

    标签: android xamarin microsoft-graph-api msal cookiemanager


    【解决方案1】:

    固定。

    从 Chrome 自定义选项卡切换到嵌入式(WebView?)允许您通过 CookieManager 管理 cookie。

    App.UiParent = new UIParent(Xamarin.Forms.Forms.Context as Activity, true);

    https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/MSAL.NET-uses-web-browser#choosing-between-embedded-web-browser-or-system-browser-on-xamarinandroid

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-22
      • 2011-02-19
      • 1970-01-01
      • 2020-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      相关资源
      最近更新 更多