How to download files from google drive through PHP?

Follow the examples here: https://developers.google.com/drive/v3/web/quickst...
And here: https://developers.google.com/drive/v3/web/manage-...

A list of disk files are already removed, you need to do the download. But here was the catch.
Right put wide: https://www.googleapis.com/auth/drive
Trying to get the file to the following (the project on Yii2):
public function actionDownload($fileId)
{
 $service = GoogleDocsConsole::getService(); // Instance Google_Service_Drive 
 $response = $service->files->export($fileId, 'application/pdf', [
 'alt' => 'media'
]);

 $content = $response->getBody()->getContents();
 return $content;
}

In the end I see the error:
Google_Service_Exception
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}


What am I doing wrong?
June 7th 19 at 15:05
0 answer

Find more questions by tags PHPAPIGoogle Drive