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

久未见 提交于 2019-12-08 14:04:00

问题


I am writing a Windows Phone 8 app which will use the Microsoft Account to authenticate a user (Via Azure Mobile Services)

I have followed the instructions here: 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.

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.


回答1:


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

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. (For more on generating an auth token, look here: http://www.thejoyofcode.com/Generating_your_own_ZUMO_auth_token_Day_8_.aspx)

In 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:

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

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


来源:https://stackoverflow.com/questions/16038696/windows-phone-8-azure-mobiles-services-keep-me-signed-in-microsoft-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!