AuthenticationToken is null

天涯浪子 提交于 2019-12-22 11:23:17

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/9572779/authenticationtoken-is-null

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