我使用facebook的自定義身份驗證讓我的用戶登錄到應用程序服務。不幸的是我打電話「InvokeApiAsync」時,收到以下錯誤Azure移動應用程序即使在成功登錄後也會返回401(未授權)。
「Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException:請求無法完成(未授權)。」
我用下面的代碼工作與NuGet包的1.xx分支,它只有在更新後我得到這個錯誤信息。
Newtonsoft.Json.Linq.JObject jToken = new Newtonsoft.Json.Linq.JObject();
jToken.Add("access_token", token);
var user = await _mobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook, jToken);
var result= await _mobileService.InvokeApiAsync<GetContactListRequest, GetContactListResponse>("GetContactList", new GetContactListRequest());
的LoginAsync部分作品和用戶變量包含與令牌的用戶(_mobileService.CurrentUser確實以及)。這是當我稱之爲「InvokeApiAsync我得到的未經授權的錯誤。
移動業務
[Authorize]
public class GetContactListController : ApiController
{
// POST api/CustomRegistration
public HttpResponseMessage Post(GetContactListRequest request)
{
try
{
return this.Request.CreateResponse(HttpStatusCode.OK, new GetContactListResponse());
}
catch (Exception ex)
{
return this.Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
}
}
}
任何指針?
您是使用自定義身份驗證還是使用內置的Facebook身份驗證?看起來你正在使用後者。如果您打開應用程序日誌記錄,您是否看到任何錯誤? –
我正在使用自定義身份驗證,其中我從(成功的)LoginAsync調用中使用我的Facebook令牌的位置 – Bosch571