Search code examples
permissionsgoogle-drive-apiscopes

Web app can create a Google Drive Folder, how can it list files inside that it didn't create?


I'm trying to be a good citizen and use the drive.file scope, but I'm hitting some snags and not entirely sure how to work through them.

Overview:

  1. user logs into my application, which uses drive.file scope
  2. my application creates a new Folder in the user's Drive, then creates a File in that folder
  3. the user adds new files to that Folder on their own through the Drive interface
  4. my application searches that Folder and only finds the files it created

How do I allow my web app to read ALL of the files inside of a folder it has created, not just the files it has also created?

I had assumed the answer was in the Permissions API, that perhaps I would create a new Permission, but the docs don't seem to make sense for an API client. Would it be a "user" type permission? If so, I must provide an email address parameter, but what email address should be used for the client? Would it be a "domain" type permission? What domain would I use? Am I just searching for files wrong, and some option would expose the other files to my app?

Thanks in advance!


Solution

  • The documentation specifies that drive.file gives only Per-file access to files created or opened by the app

    If you see the descriptions of all other possible scopes, you will relaize that unfortunately there is no such scope that gives you access to all files in a certain folder, but not to any other folder on user's drive.

    Thus, the scopes will not help you here.

    If you want to have access only to files in a certain folder, you need to implement a workaround.

    E.g., you can deploy the WebApp as "You" and ask the user to share the folder of interest with you. Then, the WebApp will only have access to the respective folder.