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登录凭据不会被缓存。
固定。
从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/mmsal.net-sal.net-uses-web-browser#choosing-choosing-choosing-betthe-bet-bet--embedded-embedded-web-browser- or-system-system-system-browser - Xamarinandroid