Я использую Google Sheet Api на платформе PHP и сталкиваюсь с ошибкой при обновлении листа.
Fatal error: Uncaught Google_Service_Exception: {
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"errors": [
{
"message": "Request had insufficient authentication scopes.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
Как это исправить?
function add($spreadsheetId, $range, $value, $service){
$result = $service->spreadsheets_values->get($spreadsheetId, $range);
$numRows = $result->getValues() != null ? count($result->getValues()) : 0;
printf("%d rows retrieved.", $numRows);
$body = new Google_Service_Sheets_ValueRange([
'values' => [$value]
]);
$end = chr(65 + count($value) - 1);
$range = $range."!A".($numRows + 1).":".$end;//ex:Sheet!A6:H
printf("%s\n", $range);
$result = $service->spreadsheets_values->update($spreadsheetId, $range, $body, ['valueInputOption' => 'USER_ENTERED']);
printf("%d cells added.\n", $result->getUpdatedCells());
}