Facebook login using oauth not working on real server

I use OAuthWebSecurity to login to facebook and it works on localhost. However, after deployment to a real server, the following error message appears:

The remote server returned an error: (400) Bad request.

  • I checked the domain information correctly on facebook.
  • Sandbox mode is disabled.
  • I disabled the windows firewall - still getting the same error.
  • The answers from facebook are in the same format, whether in a live or local environment.
  • The date and time of the real server is correct.

I tested locally also changing the host file in the real domain - it still works locally.

Here's the stack trace:

[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

Any suggestions?

+5
source share
2 answers

, 400 Facebook, dotnetopenoath, MVC 4 , , , , , ( ):

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);
                }
             }
         }
    }
}
+1

All Articles