title: php Google spreadsheet API "Request had insufficient authentication scopes"
body: <p>i have a Problem with the Spreadsheed api and the "scopes".
  With these script i want to update Cells on a Sheet.</p>
  
  <p>I do not work with composer ich have just download the package in intereating it. The Token is already there and the error is from these row:</p>
  
  <p>"$response = $service->spreadsheets_values->get($spreadsheetId, $range);"</p>
  
  <pre><code>&lt;?php
  session_start();
  require_once __DIR__.'/vendor/autoload.php';
  
  $client = new Google_Client();
  $client-&gt;setAuthConfig('oauth-credentials.json');
  
  $client-&gt;addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
  
  if (isset($_SESSION['access_token']) &amp;&amp; $_SESSION['access_token']) 
  {
        $client-&gt;setAccessToken($_SESSION['access_token']);
  
        echo "&lt;pre&gt;";   
        $service = new Google_Service_Sheets($client);
        $spreadsheetId = 'xxx';
        $range = 'Tabellenblatt1!A2:E';
  
          $response = $service-&gt;spreadsheets_values-&gt;get($spreadsheetId, $range);
          $values = $response-&gt;getValues();
  
          if (count($values) == 0) {
            print "No data found.\n";
          } else {
            print "Name, Major:\n";
            foreach ($values as $row) {
              // Print columns A and E, which correspond to indices 0 and 4.
              printf("%s, %s &lt;br&gt;", $row[0], $row[4]);
            }
          }
      } else {
        $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/api/oauth2callback.php';
  
        header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
      }
  ?&gt;
  </code></pre>
  
  <p>These Code brings the following Error</p>
  
  <pre><code>Fatal error:  Uncaught exception 'Google_Service_Exception' with message '{
    "error": {
      "code": 403,
      "message": "Request had insufficient authentication scopes.",
      "errors": [
        {
          "message": "Request had insufficient authentication scopes.",
          "domain": "global",
          "reason": "forbidden"
        }
      ],
      "status": "PERMISSION_DENIED"
    }
  }
  </code></pre>