如何使用 Google 身份验证在 Microsoft MobileServiceClient 上切换用户
How to switch users on Microsoft MobileServiceClient with Google authentication
我有一个使用 Azure MobileServiceClient (DataService.client) 的 Xamarin Android 应用程序。它被设置为使用 Google 身份验证。我登录如下:
var user = await DataService.client.LoginAsync(this,
MobileServiceAuthenticationProvider.Google, "myapp");
效果很好。它打开一个浏览器到 Google 登录页面,然后您登录。一旦您在 android 设备上执行此操作一次,它就不再提示您输入登录信息。我有一种情况,我想以不同的用户身份登录以测试一些内部应用程序权限。我创建了一个注销功能如下:
await DataService.client.LogoutAsync();
这会将您注销,但下次您需要进行身份验证时,它不会提示您输入凭据。它会将您重新登录为同一个人。有没有办法清除登录信息,以便它再次询问您的用户名?
AFAIK,MobileServiceClient.LogoutAsync()
只是清除移动客户端中当前 MobileServiceClient 实例的 MobileServiceClient.CurrentUser
。为了完全登出,您需要在执行MobileServiceClient.LogoutAsync()
.
之前手动发送一个登出请求到您的移动后台如下
Get https://{your-app-name}.azurewebsites.net/.auth/logout
Header X-ZUMO-AUTH:{MobileServiceClient.CurrentUser.MobileServiceAuthenticationToken}
详情请参考 adrian hall 关于 Implementing a LogoutAsync() method 的书。
我有一个使用 Azure MobileServiceClient (DataService.client) 的 Xamarin Android 应用程序。它被设置为使用 Google 身份验证。我登录如下:
var user = await DataService.client.LoginAsync(this,
MobileServiceAuthenticationProvider.Google, "myapp");
效果很好。它打开一个浏览器到 Google 登录页面,然后您登录。一旦您在 android 设备上执行此操作一次,它就不再提示您输入登录信息。我有一种情况,我想以不同的用户身份登录以测试一些内部应用程序权限。我创建了一个注销功能如下:
await DataService.client.LogoutAsync();
这会将您注销,但下次您需要进行身份验证时,它不会提示您输入凭据。它会将您重新登录为同一个人。有没有办法清除登录信息,以便它再次询问您的用户名?
AFAIK,MobileServiceClient.LogoutAsync()
只是清除移动客户端中当前 MobileServiceClient 实例的 MobileServiceClient.CurrentUser
。为了完全登出,您需要在执行MobileServiceClient.LogoutAsync()
.
Get https://{your-app-name}.azurewebsites.net/.auth/logout
Header X-ZUMO-AUTH:{MobileServiceClient.CurrentUser.MobileServiceAuthenticationToken}
详情请参考 adrian hall 关于 Implementing a LogoutAsync() method 的书。