I want to retrieve list of files from a Google drive folder. Authentication happens through Service account. Here is my code to do the same:
final _credentials =
The service account is different from your Google account. This means that the Google Drive is also different between Service account and your account. So when the file is retrieved using Service account, please share the files in your Google Drive with the Service account. By this, the files in your Google Drive can be retrieved by the Service account.
In your script, DriveFileScope
and SpreadsheetsScope
are used as the scopes. DriveFileScope
is https://www.googleapis.com/auth/drive.file
. The official document says this scope as follows.
View and manage Google Drive files and folders that you have opened or created with this app
By this, in your script, how about modifying DriveFileScope
as follows?
DriveReadonlyScope
(https://www.googleapis.com/auth/drive.readonly
)DriveScope
(https://www.googleapis.com/auth/drive
)DriveApi.driveMetadataReadOnlyScope
(https://www.googleapis.com/auth/drive.metadata.readonly
)