简体   繁体   English

Windows Phone 8 Azure移动服务-使我保持登录状态(Microsoft帐户)

[英]Windows Phone 8 Azure Mobiles Services - Keep me signed in (Microsoft Account)

I am writing a Windows Phone 8 app which will use the Microsoft Account to authenticate a user (Via Azure Mobile Services) 我正在编写Windows Phone 8应用程序,它将使用Microsoft帐户来验证用户身份(通过Azure移动服务)

I have followed the instructions here: http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-microsoft-authentication/ 我已按照此处的说明进行操作: http : //www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-microsoft-authentication/

Everything works as expected I get a user ID token back from the service and I use this to identify the user's assets in my system. 一切都按预期进行,我从服务获得了用户ID令牌,并使用它来识别系统中用户的资产。

Problem: Every time I run the App, It wants me to log in. Ticking the Keep Me Signed In check box when logging in just remembers the account email address. 问题:每次我运行该应用程序时,它都希望我登录。在登录时勾选使我保持登录状态复选框仅会记住该帐户的电子邮件地址。 It always asked for the password. 它总是要求输入密码。

Is there something I need to do to get the "Keep me signed in" to actually keep the user signed in for this application. 我需要做些什么来获得“保持登录状态”,以使用户保持该应用程序的实际登录状态。

This blog will walk you through how to fix that issue: http://www.thejoyofcode.com/Setting_the_auth_token_in_the_Mobile_Services_client_and_caching_the_user_rsquo_s_identity_Day_10_.aspx 该博客将引导您逐步解决该问题: http : //www.thejoyofcode.com/Setting_the_auth_token_in_the_Mobile_Services_client_and_caching_the_user_rsquo_s_identity_Day_10_.aspx

You're going to have to manually 'log the user in' rather than using the provided login methods. 您将不得不手动“登录用户”,而不是使用提供的登录方法。 To do this, set the user object on the Mobile Service client instance. 为此,请在Mobile Service客户端实例上设置用户对象。 (For more on generating an auth token, look here: http://www.thejoyofcode.com/Generating_your_own_ZUMO_auth_token_Day_8_.aspx ) (有关生成身份验证令牌的更多信息,请参见此处: http : //www.thejoyofcode.com/Generating_your_own_ZUMO_auth_token_Day_8_.aspx

In C#: 在C#中:

var mobileServiceClient = new MobileServiceClient("<your-app-url>", "<your-app-key>");
mobileServiceClient.CurrentUser = new MobileServiceUser("Foo:123456789");
mobileServiceClient.CurrentUser.MobileServiceAuthenticationToken = "<your-users-JWT>";

In JS: 在JS中:

var client = new Microsoft.WindowsAzure.MobileServices.MobileServiceClient(
    "<your-app-url>",
    "<your-app-key>");

client.currentUser = {
    userId: "Foo:123456789",
    mobileServiceAuthenticationToken: "<your-users-JWT>"
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM