Search code examples
facebookaccess-tokenbad-request

Facebook access token graph API call result in a bad request error


We have a Canvas Facebook App and for some time we get a strange error for some of the users that are trying to install (allow) our Facebook app. I mention this is happening only for some of the users and not for all! The error we are getting is "The remote server returned an error: (400) Bad Request." The graph API call we putted in a try catch block and this is what the logs says when I searched over them to see what went wrong. The graph API call is: https://graph.facebook.com/oauth/access_token?client_id=XXX&redirect_uri=XXX&client_secret=XXX&code=code_received_from_facebook.

We received the code from Facebook and append it to the graph API call from above but it seems that for some users this is not working. Our redirect_uri parameters contains an URL to our Facebook App and contains also some parameters (example: http://apps.facebook.com/our_application_URL?cid=xxx&surveyid=xxx&messageid=xxx). xxx = some values.

Did some of you confront with this kind of strange behavior? Working for some users but for other is not working? We are using the same code so nothing change between a successful installation and a unsuccessful installation.

Thank you for your help in advance!


Solution

  • Now that Facebook require SSL for applications your "redirect_uri" need to be https (i.e https://apps.facebook.com/myapp/), otherwhise you will get "Bad Request".

    You probably got the error for only the users that had forced SSL but not the rest.