Google Drive PHP API:如何获取由我的应用创建的文件夹中的所有文件,由用户或其他应用放置在那里

So Google Drive has a lot of security, which is a good thing. By default, my app can only get the files it has itself created on the user's drive. However, I also need to be able to retrieve all files placed by the user (or another app) in one of the folders that my app created.

Example:

  • My app creates a folder called "Stuff"
  • Now the user manually uploads a file called "test.txt" and places it in "Stuff".
  • My app can't see this file, even though the app created the folder that the file is in. This is what I'd like to fix.

In addition, I have seen code on stackoverflow and other places which gives my app access to the user's ENTIRE google drive, but I'd like to avoid doing that. I only need access to the files created inside folders created by my app, not everything. Besides, the code that I found about this was all from 2012 or earlier and doesn't work anymore due to undocumented changes in the PHP API.

Any help would be appreciated.

It appears to be impossible. I was forced to give my app access to the user's entire drive. Here's the relevant code:

$client->setScopes(implode(' ', array(
    Google_Service_Drive::DRIVE,
)));

If anyone has a better solution, I'd love to hear it.

The user needs to open the newly uploaded file with your app in order that you have access to it. I had a similar problem and used a workaround described here: Drive API for Android unable to access the file created by same App