【问题标题】:How to switch users on Microsoft MobileServiceClient with Google authentication如何使用 Google 身份验证在 Microsoft MobileServiceClient 上切换用户
【发布时间】:2018-04-29 22:52:58
【问题描述】:

我有一个使用 Azure MobileServiceClient (DataService.client) 的 Xamarin Android 应用。它设置为使用 Google 身份验证。我登录如下:

          var user = await DataService.client.LoginAsync(this,
                MobileServiceAuthenticationProvider.Google, "myapp");

这很好用。它会打开一个浏览器到 Google 登录页面,然后您登录。一旦您在您的 android 设备上执行此操作,它就不再提示您输入登录信息。我有一种情况,我想以其他用户身份登录以测试一些内部应用程序权限。我创建了一个注销功能如下:

        await DataService.client.LogoutAsync();

这会将您注销,但下次您需要进行身份验证时,它不会提示您输入凭据。它会让您以同一个人的身份重新登录。有没有办法清除登录信息,让它再次询问您的用户名?

【问题讨论】:

    标签: android azure xamarin xamarin.android azure-mobile-services


    【解决方案1】:

    AFAIK,MobileServiceClient.LogoutAsync() 只是清除移动客户端中当前 MobileServiceClient 实例的 MobileServiceClient.CurrentUser。为了完全登出,您需要在执行MobileServiceClient.LogoutAsync()之前手动向您的移动后端发送登出请求,如下所示。

    Get https://{your-app-name}.azurewebsites.net/.auth/logout
    Header X-ZUMO-AUTH:{MobileServiceClient.CurrentUser.MobileServiceAuthenticationToken}
    

    你可以关注阿德里安霍尔关于Implementing a LogoutAsync() method的书。

    【讨论】:

    • 我会试一试。谢谢!
    猜你喜欢
    • 2018-08-28
    • 2015-03-24
    • 2020-11-15
    • 2014-06-22
    • 2020-12-10
    • 1970-01-01
    • 2022-08-19
    • 2018-01-07
    • 2018-01-21
    相关资源
    最近更新 更多