title: PHP Google Sheets API - Permission Denied
body: <p>Hi I've just started to study PHP and I'm attempting to use the Google sheets API.</p>
  
  <p>I thought I followed their instructions and I could call and edit sheet data well but only Public Access.</p>
  
  <p>When I change access status as private or Group, I encounter message below.</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'Google_Service_Exception' with message '{
    "error": {
      "code": 403,
      "message": "The caller does not have permission",
      "errors": [
        {
          "message": "The caller does not have permission",
          "domain": "global",
          "reason": "forbidden"
        }
      ],
      "status": "PERMISSION_DENIED"
    }
  }
  </code></pre>
  
  <p>And I will put my codes what you would see to help.</p>
  
  <pre><code>&lt;?php
  require_once __DIR__ . '/vendor/autoload.php';
  
  define('APPLICATION_NAME', 'Google Sheets API PHP Quickstart');
  define('CREDENTIALS_PATH', __DIR__ . '/service-account-credentials.json');
  define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
  define('SCOPES', implode(' ', array(
          Google_Service_Sheets::SPREADSHEETS)
  ));
  
  putenv('GOOGLE_APPLICATION_CREDENTIALS='.CREDENTIALS_PATH);
  
  $client = new Google_Client();
  $client-&gt;useApplicationDefaultCredentials();
  $client-&gt;addScope(Google_Service_Drive::DRIVE);
  
  $client-&gt;setApplicationName(APPLICATION_NAME);
  $client-&gt;setScopes(SCOPES);
  
  $tokenArray = $client-&gt;fetchAccessTokenWithAssertion();
  $accessToken = $tokenArray["access_token"];
  
  $service = new Google_Service_Sheets($client);
  
  $spreadsheetId = "1qe7QwyYxWuIAYT7UUZ2s3KdDZrAHJ02uPH4VPrr-pMk";
  
  $range = "Sheet1";
  $response = $service-&gt;spreadsheets_values-&gt;get($spreadsheetId, $range);
  $values = $response-&gt;getValues();
  if (count($values) == 0) {
      print "No data found.\n";
  }
  print_r($values);
  </code></pre>
  
  <p>Is there anything to confirm in the code? or google API console?</p>
  
  <p>Any information would be greatly appreciated! thanks in advance!</p>