2

I have a standard ASP.NET MVC 4 site which uses the built-in OAuthWebSecurity to allow people to login with their Microsoft Accounts (LiveId). The site and the login works OK. The site contains a controller which requires authentication and returns JSON. This also works OK.

I now need to be able to access this same controller using a WebClient from a Windows Phone app. I'm currently trying to implement this with the following method:

1.Retrieve the authentication token using the Live SDK:

var login = await authClient.LoginAsync(reqs);

var authToken = login.Session.AuthenticationToken;

2.Use the authentication token to perform login with the ASP.NET MVC site using WebClient.

? 

And this is where I'm stuck. I haven't been able to figure out how could I do the login using an existing authentication token. Any ideas?

I think this should be doable, as the Azure Mobile Services uses a similar method. The Azure Mobile Service provides an option to authenticate with an existing token, so for example this works:

        var authClient = new LiveAuthClient("myclientid");
        ...

        var login = await authClient.LoginAsync(reqs);
        ...
        var user = await mobileServiceClient.LoginAsync(login.Session.AuthenticationToken);

Or am I approaching this from a wrong angle?

Mikael Koskinen
  • 12,306
  • 5
  • 48
  • 63

0 Answers0