3

We have a web service that needs to indentify a user accross his devices, wp8, and win8.

On the phone side we have UserExtendedProperties.GetValue("ANID2"), which get's the anonymous microsoft id.

On Windows8 there's OnlineIdAuthenticator.AuthenticateUserAsync with UserIdentity.SafeCustomerId and other properties, though none of them look like the ANID2.

The OnlineIdAuthenticator api exists on phone, but throws NotImplementedException.

Is there any way to get a common user identifier on win8 and wp8?

Thanks

sharp johnny
  • 814
  • 6
  • 16

1 Answers1

1

The best way I know (it's apparently the recommended way too) is to use Azure Mobile Services (http://www.windowsazure.com/en-us/home/scenarios/mobile-services/). There is a free plan that you can use. With Mobile Services you can use the MobileServiceClient (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.mobileservices.mobileserviceclient.aspx) to get a unique ID for each user (based on the MS account).

This code gets the user ID:

MobileServiceClient client = new MobileServiceClient(serviceUri);
MobileServiceUser user = await client.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount);

/* The user ID contains the provider name and the ID seperated by a colon */
var userId = user.UserId.Split(':').Last();

You can find some more information here: http://msdn.microsoft.com/en-us/library/jj863454.aspx and the SDK here: http://www.windowsazure.com/en-us/develop/mobile/developer-tools/

calum
  • 1,580
  • 10
  • 11
  • Thanks. One question, will this result in a login prompt(especially on the phone side)? – sharp johnny Apr 18 '13 at 07:48
  • Yes, it opens a web page prompting the user to log-in. Looks like a standard OAuth page. Just like with OAuth there is no way to get the users password or email, so you can make a note of this before sending the user to the log-in page. If you want to see it in action check out Unification. – calum Apr 18 '13 at 08:51