Search code examples
c#windows-store-appssingle-sign-onazure-mobile-serviceslive-sdk

Login with Microsoft account using Live SDK


I am creating a Windows 8.1 application, and I want to use it with multiple accounts. When I first started the application, I used the wl.signin scope to test the app faster, but I want to test now with other account(s). So I deleted this scope, I uninstalled the app from my computer, and from my Live Account I removed the apps permissions.

Still, if I want to log in for the first time, the app wants permission for automatic login(== wl.signin, which I deleted from my scopes already as I mentioned before).

Basically, I want to achieve to write my user credentials every time I want to use the app so I could login with other accounts.

Here is the code for login:

LiveLoginResult result = await App.Auth.InitializeAsync(new string[] { "wl.basic" });
if (result.Status != LiveConnectSessionStatus.Connected)
    result = await App.Auth.LoginAsync(new string[] { "wl.basic" });

if (result.Status == LiveConnectSessionStatus.Connected)
{
    await App.MobileService.LoginWithMicrosoftAccountAsync(
        result.Session.AuthenticationToken);
    App.Lcs = result.Session;                    
}
else
{
    await dialogService.ShowMessage("Not logged in.", "Error!");
}

And if I try to log out, the CanLogout always returns with false value.

if (App.Auth.CanLogout)
{
    App.Auth.Logout();
    navigationService.NavigateTo("MainPage");
}

What am I missing here? Maybe the scopes cached somewhere else? Could that be a problem if I use the operating system with Microsoft Account? Or if I associated the app with a Store app with Visual Studio?


Solution

  • It's not possible with LiveSdk. Because LiveSdk uses account info from the system. The only way to use few accounts at once, is to develop an own SDK via LIVE REST API (as in the LiveSDK internally).