gpt4 book ai didi

c# - 无法注销 Azure Rms 移动服务用户

转载 作者:行者123 更新时间:2023-12-03 06:02:33 25 4
gpt4 key购买 nike

一如既往:我很菜鸟,正如你从问题中可能看到的那样。

我正在 Xamarin.Android 中使用 Azure Wams,它似乎是一个很棒的工具。它大大登录Xamarin.Android中的用户。当我希望用户能够注销然后使用另一个帐户登录(我使用 Google 进行身份验证)时,我的问题就出现了。我曾经可以通过注销按钮使用它,如下所示:

登录时,AuthenticationToken 会保存在字符串中以供以后使用。因此,当用户确认他想要注销时,我只需 UserAuth = String.Empty,然后再次调用 ConnectToMobileService():

public async Task ConnectToMobileService ()
{
try
{
CurrentPlatform.Init ();

client = new MobileServiceClient(
Constants.ApplicationURL,
Constants.ApplicationKey, progressHandler);

if (string.IsNullOrEmpty(UserAuth)) {
await Authenticate();
UserId = user.UserId;
await CreateTables();
await CheckUserId ();
}
else if (!string.IsNullOrEmpty(UserAuth)) {
client.CurrentUser = new MobileServiceUser(UserId);
client.CurrentUser.MobileServiceAuthenticationToken = (UserAuth);
await CreateTables();
}
}
catch (Exception e)
{
CreateAndShowDialog(e, "Error");
}
}

这用于为我重新启动身份验证窗口,并且用户使用他的新帐户登录 - 同时信息保存在首选项中以用于其他事件等。嗯,更新 Xamarin 并将我的许可证升级到 Indie 后,情况不再如此。现在,它会启动短暂的“身份验证”,然后直接返回,就像用户按照之前的方式登录一样。

我意识到这可能是因为在某个地方为 Wams 保存了一些共享首选项。我研究了清除这些 Java 的方法,但我无法在 C# 中重新创建它们。

client.Logout()似乎并不能单独清除它们。这就是我尝试重新创建其余部分的方法:

private void ClearPreferences(){
var prefs = this.GetSharedPreferences("UserDate", 0);
var editor = prefs.Edit ();
editor.Clear ();
editor.Commit ();

}

这没有任何作用。那么,有人可以帮助我吗?我如何重置它,以便用户能够使用另一个帐户登录 - 或者例如让 friend 在他们的手机上登录?提前致谢!

最佳答案

好的,事实证明该信息由身份验证提供商存储为 cookie。您必须注销并清除 cookie。然后它就像一个魅力一样发挥作用。清除 cookie 的方法如下:

client.Logout ();
ClearCookies ();
await ConnectToMobileService ();
}

public static void ClearCookies () {
Android.Webkit.CookieSyncManager.CreateInstance (Android.App.Application.Context);
Android.Webkit.CookieManager.Instance.RemoveAllCookie ();
}

关于c# - 无法注销 Azure Rms 移动服务用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24083715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com