3

We would like access to a client’s folder within their Google Drive and all files under that folder. This can either be a folder we create from the app or a folder the client picks.

  1. The first approach I tried was to create the folder from the app. The problem is that I am only able to list the folder itself, but NONE of the content. https://developers.google.com/drive/api/v3/folder
  2. The second approach was to use the Google Picker API. There the client can choose which folder(s) to give us access to. However we can only get access to the folder, and none of the children folders/files. https://developers.google.com/picker/docs

This seemed like an easy and straightforward use case. But can’t seem to find a solution in their documentation, or maybe I don’t comprehend some of the logic. A solution would be a way to either propagate the permission to all the files included in the folder it get’s picked or created… or to have the picker select all the children.



My preference is to continue with the Recommended scope https://www.googleapis.com/auth/drive.file . And it might be that the folder contains thousands of individual files multiple levels in, so it’s not a solution to manually pick the files. Any thoughts on this would be greatly appreciated, thank you!

slownage
  • 154
  • 1
  • 3
  • 11

2 Answers2

1

A possible solution for your situation...

Is to create the folder in a shared drive.

Therefore, even though new files are added/updated/removed you will still be able to see all the updates and retrieve the information needed as you will have constant access to this folder.

Another solution which is more cumbersome...

Is to ask for user's permission and to re-authorize the application each time they are using it so in the case a new file is added you will have access to it.

Reference

ale13
  • 5,679
  • 3
  • 10
  • 25
  • Hi Ale13, thank you for your answer. 1. Didn't know about shared drive, however when looking more into it, it's a feature only for G Suite Accounts. Most of our clients are small businesses so we can't really use that. 2. The second solution about reauthorising every single time is not that bad, but how do you get access to also the files included in the folder? If you pick it you only get to see the folder but not the content within. – slownage Jul 22 '21 at 18:42
1

enter image description here

The first approach I tried was to create the folder from the app. The problem is that I am only able to list the folder itself, but NONE of the content. https://developers.google.com/drive/api/v3/folder

The issue is probably the scope you authorized the user with. If you authorized with read only access your not going to be able to create you need full drive access to do that.

If you are using https://www.googleapis.com/auth/drive.file then you should create a folder with that and then create a file in the folder that i believe should work.

The second approach was to use the Google Picker API. There the client can choose which folder(s) to give us access to. However we can only get access to the folder, and none of the children folders/files. https://developers.google.com/picker/docs

There is no way to request access for a single folder or files. Its all or nothing really unless you use the https://www.googleapis.com/auth/drive.file scope which would only give you access to the files that your application created.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449