Question

I am trying to build Single Sign On functionality into my C++ Store app using Live SDK and Azure Mobile Services (similar to what is described for .NET apps here).

I am using Azure Mobile C++ Library and the live_connect.h wrapper. Below is what my code looks like:

void MapQuizVC12::StartPage::LoginIntoLive()
{
       LiveClient->login(L"wl.basic wl.signin").then([this](bool isLoggedIn)
       {
              LiveClient->get(L"me").then([this](json::value v)
              {
                     auto token = json::value::object();
                     token[L"authenticationToken"] = json::value::string(LiveClient->authentication_token());

                     AzureMobileHelper::mapquizMobileService::GetClient()
                           .login(azure::mobile::authentication_provider::microsoft, token)
                           .then([](task<azure::mobile::user> user)
                     {
                           try
                           {
                                  user.wait();
                           }
                           catch (std::exception e)
                           {
                           }
                     }, concurrency::task_continuation_context::use_current());
              }, concurrency::task_continuation_context::use_current());
       }, concurrency::task_continuation_context::use_current());
}

The Live authentication seems to work fine but when I use the auth token to login to Zumo, I get the following exception in the catch block above:

Exception while logging into Azure Mobile Service using existing auth token

After some playing around. I figured that the Live authToken being returned by the C# SDK is different from the one that is being returned by the C++ API. Azure Mobile service actually expects what is returned by the C# SDK. I have posted about this problem here.

What am I doing wrong?

Was it helpful?

Solution

The problem turned out to be with the token that Live REST API was returning in C++. It seems the correct information was not being requested through the WinRT API used to authenticate with the Live Service. Fixing that fixes this issue.

The correct code snippet has been posted on this MSDN Forums post.

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