Live Integration

Mar 11, 2014 at 1:58 PM
Hi all,

I am checking how to integrate Casablanca into a Windows Store app. I am using VS2013 Express.

For that, I am created a new project using the XAML with Direct3D template. Added the Casablanca using NuGet. Reserved an app name on the portal, and associated the app in VS.
Under Services, I have checked the Live Services Site, and my app has SID, Application Identity and everything. In the app manifest, the Internet (Client) permission is enabled.

Into the DirectXPage::OnPointerPressed funtion, I have copy/pasted the login code from the Live sample:
static web::live::live_client lv_client;

void DirectXPage::OnPointerPressed(Object^ sender, PointerEventArgs^ e)
{
    // When the pointer is pressed begin tracking the pointer movement.
    m_main->StartTracking();

  try
  {
    auto ui_ctx = pplx::task_continuation_context::use_current();

    std::vector<utility::string_t> scopes;
    scopes.push_back( web::live::scopes::wl_basic );
    scopes.push_back( web::live::scopes::wl_skydrive );
    scopes.push_back( web::live::scopes::wl_skydrive_update );
    lv_client.login( std::begin( scopes ), std::end( scopes ) ).then( [ this ] ( bool ok )
    {
      if ( ok )
      {
        const wchar_t* authToken = lv_client.authentication_token().c_str();
        rand();
      }
      else
      {
        rand();
      }
    }, ui_ctx );
  }
  catch ( ... )
  {
  }
}
Compiles just fine. When I run it and touch the screen, I get a nice exception:
First-chance exception at 0x75AD3D67 (KernelBase.dll) in App1.exe: 0x40080202: WinRT transform error (parameters: 0x80000019, 0x80070032, 0x0000001F, 0x05D0E2E0).
First-chance exception at 0x75AD3D67 in App1.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x05D0E77C. HRESULT:0x80070032 The request is not supported.
WinRT information: The request is not supported.
Stack trace:
[External Code]
App1.exe!web::live::live_client::login(std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > scopes) Line 122
App1.exe!web::live::live_client::login<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > > > > >(std::_Vector_iterator<std::_Vector_val<std::_Simple_types<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > > > > begin, std::_Vector_iterator<std::_Vector_val<std::_Simple_types<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > > > > end) Line 154
App1.exe!App1::DirectXPage::OnPointerPressed(Platform::Object ^ sender, Windows::UI::Core::PointerEventArgs ^ e) Line 192
[External Code]
App1.exe!App1::DirectXPage::{ctor}::__l3::<lambda>(Windows::Foundation::IAsyncAction ^ __formal) Line 83
[External Code]
Do I have to do something else to make it work?

Thank you.

László
Mar 12, 2014 at 11:50 AM
I have made it working.

I have created a button in the xaml and moved the code to the button press function. The very same code works from there.

What are the restrictions of using the API. Like if I'd like to sign in to Live at program start to get settings, how can I do that? What are the restrictions?

Thank you,

László
Mar 25, 2014 at 1:28 AM
Hi,

For logging into Live, WindowsLiveAuth sample uses the Windows Runtime (WinRT) OnlineIdAuthenticator API. The OnlineIdAuthenticator is not a part of the C++ REST SDK.
Hence, for any queries regarding the authentication to live using this WinRT component, I would suggest trying some other forums such as:
  1. Windows Store Apps Forum
  2. Live Connect forum
Also, I am not aware of any restrictions of using the API. Is there any initialization happening when you start the Live authentication? I could successfully call the login code after the InitializeComponent(); in MainPage::MainPage().

Thanks
Kavya