Facebook OAuth access_token return HTTP 400 Error Validating Verification Code

{
   "error": {
      "type": "OAuthException",
      "message": "Error validating verification code."
   }
}

I was following the guides at Facebook Developers to do OAuth on the server side. In summary:

  1. Redirect the user to https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
  2. After user click allow, it’ll hit our Redirect Uri
  3. At that point we’ll get the code and we need to do a server side HTTP Get to the following Url to exchange the code with our oAuth access token:

    https://graph.facebook.com/oauth/access_token?

         client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&

         client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE

Now at step 3, I kept on getting Http 400 response back.

So after some research, I found out that on that redirect_uri that we submitted on step 3 doesn’t do anything but validate the request. Thus, the value need to match with step 2.

Finally! Phew.


About this entry