使用oauth的facebook登录在实时服务器上失败

时间:2013-04-21 10:02:45

标签: asp.net-mvc facebook oauth

我正在使用OAuthWebSecurity登录facebook,它正在使用localhost。但是,然后部署到实时服务器,我收到以下错误消息:

远程服务器返回错误:(400)错误请求。

  • 我在Facebook上检查过域名详情是否正确。
  • 沙箱模式已停用。
  • 我已禁用Windows防火墙 - 仍然会出现同样的错误。
  • 来自facebook的回复具有相同的格式,无论是在live或localhost环境中。
  • 实时服务器的日期和时间是正确的。

我在本地测试也将主机文件更改为实时域 - 仍在本地工作。

这是堆栈跟踪:

[WebException: The remote server returned an error: (400) Bad Request.]
System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +3291120
System.Net.WebClient.DownloadString(Uri address) +207
DotNetOpenAuth.AspNet.Clients.FacebookClient.QueryAccessToken(Uri returnUrl, String authorizationCode) +293
DotNetOpenAuth.AspNet.Clients.OAuth2Client.VerifyAuthentication(HttpContextBase context, Uri returnPageUrl) +167
DotNetOpenAuth.AspNet.OpenAuthSecurityManager.VerifyAuthentication(String returnUrl) +502
Microsoft.Web.WebPages.OAuth.OAuthWebSecurity.VerifyAuthenticationCore(HttpContextBase context, String returnUrl) +231

有什么建议吗?

2 个答案:

答案 0 :(得分:1)

有一个与此相关的缺陷: https://github.com/DotNetOpenAuth/DotNetOpenAuth/issues/203

但显然不再维护该库: https://github.com/DotNetOpenAuth/DotNetOpenAuth/issues/317#issuecomment-29580565

...虽然在许多Microsoft文档中仍然引用它。调查与另一个缺陷相关的问题。

另请参阅:The remote server returned an error: (400) Bad Request Microsoft.AspNet.Membership.OpenAuth

答案 1 :(得分:1)

这是一个旧版本,但是我使用dotnetopenoath从Facebook登录中遇到了400错误,因为它已集成到MVC 4中并且继续进行疯狂的追逐,认为它不起作用,因为它不再受支持,当我所有的时候需要做的是捕获并记录异常,这个异常指出了我的特定情况的问题(app秘密证明设置):

catch (WebException exception)
{
    using (WebResponse response = exception.Response)
    {
        HttpWebResponse httpResponse = (HttpWebResponse) response;
        m_log.Debug("Error code: " + httpResponse.StatusCode);
        using (Stream data = response.GetResponseStream())
        {
            if (data != null)
            {
                using (var reader = new StreamReader(data))
                {
                    string text = reader.ReadToEnd();
                    m_log.Debug(text);
                }
             }
         }
    }
}
相关问题