i have a Problem with the Spreadsheed api and the "scopes". With these script i want to update Cells on a Sheet.
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:
"$response = $service->spreadsheets_values->get($spreadsheetId, $range);"
<?php session_start(); require_once __DIR__.'/vendor/autoload.php'; $client = new Google_Client(); $client->setAuthConfig('oauth-credentials.json'); $client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY); if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { $client->setAccessToken($_SESSION['access_token']); echo "<pre>"; $service = new Google_Service_Sheets($client); $spreadsheetId = 'xxx'; $range = 'Tabellenblatt1!A2:E'; $response = $service->spreadsheets_values->get($spreadsheetId, $range); $values = $response->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 <br>", $row[0], $row[4]); } } } else { $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/api/oauth2callback.php'; header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL)); } ?> These Code brings the following Error
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" } }