title: Facebook PHP SDK - Graph returned an error: Invalid OAuth access token
body: <p>Here is my code:</p>
  
  <p>login.php:</p>
  
  <pre><code>&lt;?PHP
  require_once __DIR__ . '/Facebook/autoload.php';
  
  $fb = new Facebook\Facebook([
    'app_id' =&gt; '',
    'app_secret' =&gt; '',
    'default_graph_version' =&gt; 'v2.2',
    ]);
  
  $helper = $fb-&gt;getRedirectLoginHelper();
  $permissions = ['email','public_profile']; // optional
  $loginUrl = $helper-&gt;getLoginUrl('http://www.sportsector.bg/login-callback.php', $permissions);
  
  echo '&lt;a href="' . $loginUrl . '"&gt;Log in with Facebook!&lt;/a&gt;';
  </code></pre>
  
  <p>Here is my login-callback.php:</p>
  
  <pre><code>&lt;?PHP
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);
  session_start();
  require_once __DIR__ . '/Facebook/autoload.php';
  $fb = new Facebook\Facebook([
    'app_id' =&gt; '',
    'app_secret' =&gt; '',
    'default_graph_version' =&gt; 'v2.2',
    ]);
  
  
  try {
    // Returns a `Facebook\FacebookResponse` object
    $response = $fb-&gt;get('/me?fields=id,name', '{access-token}');
  } catch(Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e-&gt;getMessage();
    exit;
  } catch(Facebook\Exceptions\FacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e-&gt;getMessage();
    exit;
  }
  
  $user = $response-&gt;getGraphUser();
  
  echo 'Name: ' . $user['name'];
  </code></pre>
  
  <p>When i click the <code>Login with Facebook!</code> link i get redirected to Facebook where i have to click continue. After that i get back on my website receiving the following error:</p>
  
  <pre><code>Graph returned an error: Invalid OAuth access token.
  </code></pre>
  
  <p>Can somebody tell me where is my mistake and how can i fix this?</p>