admin管理员组

文章数量:1296875

I have a PHP app needing to query all subfolders of a target folder, to create galleries fetching the subfolder images.

Until now I used the drive.metadata.readonly scope, but Google is not approving the app, saying it can be done using drive.file scope.

Stating the user already approved the oauth screen and grabbed its token, the folders and files query always gives me an empty array.I tried the Drive picker: it gives me the folder ID. Then I run the query based on that folder ID, but same result.

Where am I doing the mistake? Is it really possible to automatically fetch a folder contents knowing its ID with that scope?

I have a PHP app needing to query all subfolders of a target folder, to create galleries fetching the subfolder images.

Until now I used the drive.metadata.readonly scope, but Google is not approving the app, saying it can be done using drive.file scope.

Stating the user already approved the oauth screen and grabbed its token, the folders and files query always gives me an empty array.I tried the Drive picker: it gives me the folder ID. Then I run the query based on that folder ID, but same result.

Where am I doing the mistake? Is it really possible to automatically fetch a folder contents knowing its ID with that scope?

Share asked Feb 11 at 16:49 a-codera-coder 2992 silver badges14 bronze badges 1
  • If your application created that folder then you can use drve.file if it was created outside your application then you cant access it with that scope – Linda Lawton - DaImTo Commented Feb 12 at 11:08
Add a comment  | 

1 Answer 1

Reset to default 0

It's possible to get the direct children of the folder with the https://www.googleapis/drive/v3/files endpoint. Example:

https://www.googleapis/drive/v3/files?q='folderId' in parents

You wont be able, however, to get the whole tree from this, you would need to query the contents of the subfolders on demand.

Source: https://developers.google/drive/api/guides/search-files

Source: https://developers.google/drive/api/guides/ref-search-terms#file-properties

本文标签: phpAccess Google Drive folder files with drivefile scopeStack Overflow