2014-05-11 16 views
1

我已經創建了一個通用應用程序和一個天藍色的移動服務。我按照azure網站上提供的關於添加Microsoft帳戶身份驗證的教程。我正在使用最新的Live SDK用於此目的。LoginWithMicrosoftAccountAsync總是以失敗告終401

客戶端,我用這個代碼,這或多或少straigt出教程:

const string ReferralUrl = "https://my-url-here.azure-mobile.net/"; 

static MobileServiceClient MobileService = new MobileServiceClient(
      "https://my-url-here.azure-mobile.net/", 
      "my key"); 

MobileServiceUser _user; 

private LiveConnectSession _session; 
private async Task Authenticate() 
{ 
    var authClient = new LiveAuthClient(ReferralUrl); 
    while (_session == null) 
    { 
     var result = await authClient.LoginAsync(new[] { "wl.basic" }); 
     if (result.Status == LiveConnectSessionStatus.Connected) 
     { 
      _session = result.Session; 
      var client = new LiveConnectClient(result.Session); 
      var meResult = await client.GetAsync("me"); 
      return; 
     } 
     else 
     { 
      break; 
     } 
     } 

    _session = null; 
} 

public async Task<bool> Login() 
{ 
    try 
    { 
     await Authenticate(); 
     _user = await MobileService 
       .LoginWithMicrosoftAccountAsync(_session.AuthenticationToken); 
     } 
    catch (Exception ex) 
    { 
     //Debug.WriteLine(ex.Message); 
      //return false; 
    } 

    return true; 
} 

以下事實已經驗證了這個應用程序:

  • 商店入口已創建
  • 該商店條目已與通用應用程序相關聯(已針對win8.1和wp8.1項目執行此操作)
  • st礦石的應用具有以下設置:

在蔚藍門戶,在身份選項卡中,客戶端ID和密碼已輸入並保存。但是,沒有軟件包SID(本教程中也未提及)。

我下載了使用移動服務創建的服務項目並將其添加到我的解決方案中。另外,我已將SetIsHosted(true)標誌添加到WebApiConfig類中。最後,我將AuthorizeLevel屬性添加到TodoItemController並將其設置爲用戶級別。該服務已成功發佈到天藍。

當我運行我的應用程序並調用登錄時,它將導致401異常。如果我在本地運行或託管,這並不重要。

任何想法?

回答

0

此功能 - 基於客戶端SDK(用於Microsoft帳戶(Live SDK)或Facebook)的信息進行身份驗證 - 目前移動服務的.NET後端不支持該功能。 .NET後端支持的內容是通過Microsoft/Facebook/Google/Twitter的Web界面進行身份驗證,或者Azure Active Directory的客戶端身份驗證。應該在即將發佈的版本中實現對所需功能的支持。您可以查看Azure Mobile team blog以瞭解它的實時通告。