Can the Windows 8 Live SDK use another Microsoft Account other than the current user?

左心房为你撑大大i 提交于 2019-12-20 04:32:15

问题


Using the Windows 8 Live SDK you can have a user give you permission to their Microsoft Account. With this you can get their name and photo and more. But using the Live SDK appears to require the user of the app to use the same Microsoft Account as whoever is signed into the current session of Windows 8.

In some scenarios, using a different account is very legitimate.

I have simple sign-in working like a charm! This uses the same account.

I can't find a way to do use another. Is it possible?


回答1:


You can call Logout after Init and before LoginUser.

Here's the code for javascript:

function LiveLogin(){
   WL.init("<<Your clientID goes here>>");

   if (WL.canLogout()) {
       WL.logout(function () {Callback(callback);});
   }
   else{
       Callback(callback);
   }
}

function Callback(){
WL.login({ scope: ["wl.signin", "wl.basic", "wl.emails"] }, function () {
        var session = WL.getSession();
        // do stuff with your session
    });
}

And this is for C#:

LiveAuthClient liveAuthClient = new LiveAuthClient();
List<string> scopes = new List<string>();
scopes.Add("wl.signin");
scopes.Add("wl.basic");
scopes.Add("wl.emails");
LiveLoginResult loginResult = await liveAuthClient.InitializeAsync();
if (liveAuthClient.CanLogout)
{
    liveAuthClient.Logout();
}

loginResult = await liveAuthClient.LoginAsync(scopes);

It worked for me. I hope this is what you are looking for.



来源:https://stackoverflow.com/questions/13294496/can-the-windows-8-live-sdk-use-another-microsoft-account-other-than-the-current

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