Question

I'm currently writing a C# metro app for the Windows 8 consumer preview which fetches some data from my REST-based web services. I want the app to authenticate against the services using the Windows Live account of the current user. Therefore, I added the Windows Live SDK to my solution and pasted the following snippet from the documentation into my login view:

LiveAuthClient liveClient = new LiveAuthClient();                
LiveLoginResult loginResult = await liveClient.Login(new string[] { "wl.signin" });

After the login call has succeeded, I want to pass the encrypted AuthenticationToken of the LiveConnectSession via SSL to my webservice which should decrypt the token and read the information it is interested in (that's what the documentation suggests for such a SSO scenario). But sadly, the AuthenticationToken property of the session is always null. Am I missing something here?

Was it helpful?

Solution

I ran into the same problem and realised I had two issues with my configuration:

  1. I didn't have a "Redirect domain" defined in the API settings of https://manage.dev.live.com
  2. I wasn't using the overloaded LiveAuthClient constructor

For example in the API settings you specify:

Redirect domain: http://localhost/myapp

You then use the constructor overload of the LiveAuthClient:

var authClient = new LiveAuthClient("http://localhost/myapp");
var loginResult = await authClient.LoginAsync("wl-signin");

//this should no longer be null
var authToken = loginResult.Session.AuthenticationToken;

The redirect URI doesn't need to point to a working endpoint from what I can tell, as long as the two values match you should be in business.

OTHER TIPS

Have you registered your app on the Live Connect app management site for Metro style apps? You need to register it here for it to work with Live Services. It will give you following instructions after you have given the app package a name and publisher.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top