Reputation: 8586
I have created a Service Account and made this account ([email protected]) be a Manager in a Shared Drive.
I am able to retrieve the shared folder ID by running service.drives().list(pageSize=10).execute()
But if I run:
folder_id = '0ACNaJE1nx6YwXXXXXXX' # Same folder ID as above
query = "'%s' in parents" % folder_id
response = service.files().list(q=query, spaces='drive', fields='files(id, name, parents)').execute()
It returns {'files': []}
even though the shared folder contains some files. What am I doing wrong?
Upvotes: 1
Views: 1381
Reputation: 201378
I believe your goal and your current situation as follows.
service
in your script has the permission for retrieving the file list from the shared drive.In this case, how about including includeItemsFromAllDrives=True
, supportsAllDrives=True
and corpora="allDrives"
in the query parameter of the method of files.list in Drive API? When your script is modified, it becomes as follows.
folder_id = '0ACNaJE1nx6YwXXXXXXX' # Same folder ID as above
query = "'%s' in parents" % folder_id
response = service.files().list(q=query, pageSize=1000, includeItemsFromAllDrives=True, supportsAllDrives=True, corpora="allDrives", fields='files(id, name, parents)').execute()
Upvotes: 7