windows-runtimeuniqueidentifyliveid

Uniquely identify a user on WinRT and WP8 using (f.ex.) LiveID?


I am looking for a way to uniquely identify a user in WinRT and preferably in WP8 as well. In WP7 applications, I could get a hash of the Live ID to do this, but I am not sure of how to approach this in WinRT environment. One of the goals here is to identify the user in Windows 8 environment as a whole. Using LiveID in one form or another would be ok in this case. I found some sources but they also mentioned that this might require some Enterprise Security permissions (or such) that are not welcome in the Windows Marketplace.

Say I want to identify the user based on the live id, I want to do it automatically and across multiple devices (PC, Tablet, maybe WP8). What resources should I be looking for?


Solution

  • You can obtain ID of each live user if you are using Live SDK. Here's code for you.

    private async Task<string> GetLiveUserId()
    {
        string ID = "";
        var auth = new LiveAuthClient();
        var loginResult = await auth.LoginAsync(new string[] { "wl.signin", "wl.basic" });
        if (loginResult.Status == LiveConnectSessionStatus.Connected)
        {
            var liveClient = new LiveConnectClient(loginResult.Session);
            var myData = await liveClient.GetAsync("me");
            ID =  myData.Result["id"].ToString();
        }
    
        return ID;
    }