Mikos
Mikos

Reputation: 8563

Facebook oAuth 400 Error from ASP.NET application

ASP.NET application performing oAuth with Facebook. This code was working fine until a few days ago and now suddenly throws 400 errors. Cannot seem to find out why - the code has remained unchanged (verified using SVN). Can anyone help with might be the cause?

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request.

Source Error:

Line 231:        {
Line 232:                        
Line 233:            webRequest.GetResponse().GetResponseStream().Close();           
Line 234:            
Line 235:            responseReader.Close();

Upvotes: 1

Views: 2362

Answers (2)

zgirod
zgirod

Reputation: 4379

If anyone finds this page because they are/were getting a 400 error with facebook the problem for me was that my redirect URL ended with a /.

So, for your redirect URL:

http://www.website.com/oauth/callback/ - Bad
http://www.website.com/oauth/callback - Good

I hope that helps someone..

Upvotes: 1

Ganesh Krishnan
Ganesh Krishnan

Reputation: 369

No. They URLdecode the response BEFORE sending it back to you now. So if you were already decoding it at your server its double decoded and when you send it back to Facebook it throws an invalid token exception.

This was really shitty of facebook. They should have atleast warned the developers.

Upvotes: 3

Related Questions