无法通过本地.NET后端进行身份验证 [英] Can't Authenticate with Local .NET back-end

查看:101
本文介绍了无法通过本地.NET后端进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了指南:

通过Mobile Services .NET for Windows Store进行身份验证入门

只要我不需要对用户进行身份验证,就可以在本地运行该服务.如果我将服务发布到Azure,我也可以对用户进行身份验证.但我希望能够在本地测试用户身份.该怎么办?

I'm able to run the service locally as long as I don't need to authenticate the user. I can also authenticate the user if I publish the service to Azure. But I want to be able to test and authenticate the user locally. How can this be done?

我使用的是Live ID,并且在Web.config中设置了正确的ClientID和ClientSecret.当我尝试从客户端调用LoginAsync时,呼叫失败,并显示,请求无法完成. (不允许使用方法)

I'm using Live ID and I have the correct ClientID and ClientSecret set in the Web.config. When I attempt to call LoginAsync from the client the call fails with The request could not be completed. (Method Not Allowed)

** 更新2014-03-20 **

根据卡洛斯(Carlos)和亨里克(Henrik)的评论,我更新了本地服务,使其与服务器实例完全一样.我遵循了Scot Hanselmans 优秀指南,现在我的服务在本地80端口运行端口443,并带有完全有效的SSL证书.它甚至可以在完全相同的 https://xxxx.azure-mabile.net 上运行 主机名.

Based on the comments of Carlos and Henrik, I've updated my local service to look exactly like my server instance. I followed Scot Hanselmans excellent guide and now I have my service running locally on port 80 and port 443 with a completely valid SSL certificate. It's even running on the exact same https://xxxx.azure-mabile.net hostname.

有了这些更改,现在在本地计算机上运行应用程序或在Azure上运行应用程序之间没有任何配置差异.我可以在以下位置访问 https://xxxx.azure-mabile.net 浏览器,重定向到实时登录,登录,然后成功重定向回到服务.在浏览器中,一切正常.但是它 still 在应用程序中不起作用.

With these changes, there is now no configuration difference whatsoever between running the app against my local machine or running it against Azure. I can go to https://xxxx.azure-mabile.net in the browser, get redirected to Live login, sign in, and get redirected back to the service successfully. In the browser it all works. However it still doesn't work in the app.

我连接了调试器,将CLR错误设置为抛出时中断",并且设法在服务中捕获了异常.这是我在即时窗口中看到的内容:

I attached the debugger, set CLR errors to "break when thrown" and I managed to trap the exception in the service. Here's what I see in the immediate window:

Response属性没有帮助.它不提供有关该问题的任何其他信息.

The Response property is not helpful. It does not provide any additional information about the problem.

对我而言,唯一引人注意的是,该应用正在尝试对/login/microsoftaccount 进行 POST ,而浏览器通常会在在此地址> GET (然后重定向).

The only thing that stands out to me is that the app is trying to do a POST to /login/microsoftaccount while the browser would normally be doing a GET at this address (then getting redirected).

** 更新#2 2014-03-20 **

在遵循Henriks的远程调试我能够加载符号并获得 tiny 的更多信息:

After following Henriks guide for remote debugging I was able to load symbols and get a tiny bit more information:

远程主机强行关闭了现有连接"

"An existing connection was forcibly closed by the remote host"

错误代码为10054(WSAECONNRESET)对等方重置连接.

The error code is 10054 (WSAECONNRESET) Connection reset by peer.

看来,实时身份验证服务器可能会强行终止连接,但仅当我通过应用程序进行身份验证时.同样,在浏览器中进行身份验证也可以.加上/login/microsoftaccount 是应用程序中的POST的事实,似乎表明我从LiveClient.LoginAsync取回的身份验证令牌存在问题.我会做更多的挖掘工作...

It appears the Live Authentication server may be forcibly terminating the connection, but only when I'm authenticating with the app. Again, authentication within the browser is fine. This, combined with the fact that /login/microsoftaccount is a POST from the app seems to suggest there is a problem with the authentication token I'm getting back from LiveClient.LoginAsync. I'll do some more digging...

推荐答案

您是否可能在Live Connect项目中设置了Mobile client app: Yes?我认为该设置应与Live Connect SDK(客户端)流一起使用,而不是与基于浏览器的(服务器)流一起使用. .NET后端尚不支持该客户端流.

Did you perhaps set Mobile client app: Yes in your Live Connect project? I think that setting is meant to be used with the Live Connect SDK (client) flow, not the browser-based (server) flow. The client flow isn't supported yet with a .NET backend.

您还希望确保使用的是 LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount) 触发服务器流.

You also want to make sure you are using LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount) on the client to trigger the server flow.

这篇关于无法通过本地.NET后端进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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