Azure的移动服务LoginAsync与Facebook令牌是未经授权 [英] Azure Mobile Service LoginAsync with Facebook Token is Unauthorized

查看:181
本文介绍了Azure的移动服务LoginAsync与Facebook令牌是未经授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面<一职href=\"http://ntotten.com/2013/03/14/using-windows-azure-mobile-services-with-the-facebook-sdk-for-windows-phone/\" rel=\"nofollow\">http://ntotten.com/2013/03/14/using-windows-azure-mobile-services-with-the-facebook-sdk-for-windows-phone/我可以顺利拿到Facebook的访问令牌。然而,当我提交访问令牌作为 JObject MobileServiceClient.LoginAsync(供应商,令牌)方法,我得到一个 IvalidOperationException(未授权)。在code,Request和Response(从除外)均低于...

I'm following the post at http://ntotten.com/2013/03/14/using-windows-azure-mobile-services-with-the-facebook-sdk-for-windows-phone/ and I can successfully get a Facebook access token. However when I submit the access token as a JObject to the MobileServiceClient.LoginAsync(provider, token) method I get an IvalidOperationException (Unauthorized). The Code, Request and Response (from the exception) are below...

private async Task Authenticate()
{
    while (user == null)
    {
        try
        {
            fbSession = await App.FacebookSessionClient.LoginAsync("email,publish_stream,friends_about_me");
            var client = new FacebookClient(fbSession.AccessToken);
            var token = JObject.FromObject(new
            {
                access_token = fbSession.AccessToken
            });
            user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook, token); // this line causes the exception
        }
        catch (InvalidOperationException e)
        {
        }
    }
}

请求

{Method: POST, RequestUri: 'https://[MY-DOMAIN].azure-mobile.net/login/facebook', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
  X-ZUMO-INSTALLATION-ID: f13ec5fb-XXXX-XXXX-XXXX-f249415499de
  X-ZUMO-APPLICATION: jUjMFbasVpKwbktxTWcBShXXXXXXXXXX
  Accept: application/json
  User-Agent: ZUMO/1.0
  User-Agent: (lang=Managed; os=Windows Phone; os_version=8.10.0.12359; arch=Win32NT; version=1.0.20402.0)
  X-ZUMO-VERSION: ZUMO/1.0 (lang=Managed; os=Windows Phone; os_version=8.10.0.12359; arch=Win32NT; version=1.0.20402.0)
  Content-Type: application/json; charset=utf-8
  Content-Length: 223
}}

响应

{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 0.0, Content: System.Net.Http.StreamContent, Headers:
{
  Server: Microsoft-IIS/8.0
  WWW-Authenticate: Basic realm="Service"
  X-Powered-By: ASP.NET
  Set-Cookie: ARRAffinity=e1254f762d2198b2b306557ef6b226a2d9f70aac5e3cc654c3381bXXXXXXXXXX;Path=/;Domain=[MY-DOMAIN].azure-mobile.net
  Date: Sun, 20 Apr 2014 17:37:00 GMT
  Content-Length: 0
}}

如果我删除Facebook的客户端访问和充分利用 MobileServiceClient.LoginAsync(供应商)方法来代替,Facebook的身份验证成功,但我希望能够访问客户端SDK在手机上,所以我敢肯定,我已经错过了一些东西。不幸的是我所有的调试和搜索已经离开了我难住了。

If I remove the Facebook client access and leverage the MobileServiceClient.LoginAsync(provider) method instead, the Facebook authentication is successful but I want to have access to the Client SDK on the phone so I'm sure I've missed something. Unfortunately all my debugging and searching has left me stumped.

推荐答案

根据 WWW验证在我假设你正在使用的响应头。 NET后端移动业务。从接入提供商(脸谱/微软)令牌登录仍然没有在.NET后端支持。如果您使用Node.js的后端移动服务,那么你应该能够使用code在客户端登录到移动服务。

Based on the WWW-Authenticate header in the response I'm assuming you're using the .NET backend for the mobile service. Login with the token from access providers (Facebook / Microsoft) is still not supported in the .NET backend. If you use a mobile service with the node.js backend, then you should be able to use that code on the client-side to login to the mobile service.

有关客户端登录的那些供应商的支持应该在不久的将来为移动服务.NET后端。

Support for client-side login for those providers should come in the near future for the mobile services .NET backend.

这篇关于Azure的移动服务LoginAsync与Facebook令牌是未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆