Reputation: 1
I'm writing an application that downloads publicly shared Google Drive files. My application already knows the IDs of the files it needs to download. Here are three possible ways I can do this, and none of them are satisfactory:
1.) Downloading the file using the url https://drive.google.com/uc?id=<fileID>&export=download
works, but is subjected to a severe rate limit restriction because the request is sent with no authentication.
2.) Downloading the file with https://www.googleapis.com/auth/drive.file authentication doesn't work. This is because the documentation says it only provides access to "files created or opened by the app".
3.) Downloading the file with https://www.googleapis.com/auth/drive authentication works (without any other code modifications from the "drive.file" case). I can't use this option because of the required security assessment for applications that use this scope.
The only way forward seems to be using "drive.file" authentication, where these files are opened by the app. How should I do this? I think the Picker API is the intended way to do this from inside an application, but I don't see support for filtering by a specific file ID, and I would prefer a solution that doesn't require user input, especially since options (1) and (3) don't require user input.
(as a side note, the logic behind this security policy doesn't make sense to me. If (2) is not possible because of a security/authentication concern, then (1) should not be possible. If (2) is not possible because of a rate limit concern, then (3) should not be possible. I have been told that this is intended behavior.)
Upvotes: 0
Views: 484
Reputation: 2598
I understand that you are developing a web app that downloads a publicly shared Drive file. If my assumption is correct, then you only need to implement an OAuth 2.0 protocol. You can follow the basic steps as a reference. Here is a more in depth guide for web apps.
Based on this IssueTracker answer from Google, this is expected behaviour. That is, you need to open the public file in your app first and then you would be able to download it.
Upvotes: 0