Facebook Oauth 2.0 Token errors

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2010-05-16T01:58:21Z Indexed on 2010/05/16 2:10 UTC
Read the original article Hit count: 622

The user clicks the URL that is generated via the code below.

$url = 'https://graph.facebook.com/oauth/authorize?' . 
http_build_query(array('client_id'    => FACEBOOK_APP_ID,
                       'redirect_uri'   => 'http://fb.example.com/facebook',
                       'scope'          => 'publish_stream,email,offline_access,user_location,user_hometown',
                       'display'        => 'page'));

Upon granting access to the application, and redirecting to http://fb.example.com/facebook I grab the following URL using cURL.

$url = 'http://graph.facebook.com/oauth/access_token?' . 
http_build_query(array('client_id'      => FACEBOOK_APP_ID,
                       'client_secret'  => FACEBOOK_SECRET,
                       'redirect_uri'   => 'http://fb.example.com/facebook',
                       'code'           => $params['code']));

This returns the error below that I receive when grabbing the above URL.

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

Any ideas? Really getting stuck on this.

© Stack Overflow or respective owner

Related posts about facebook-api

Related posts about oauth