How to use drive.file scope in Google Docs Editor Add-on with no Google Picker?

I have a Google Docs Editor Add-on that uses the https://www.googleapis.com/auth/drive scope as a workaround, but I want to use the https://www.googleapis.com/auth/drive.file scope instead.

Ideally my user opens a Google Doc, then opens the add-on, and the add-on can only access that Doc.
The trouble is, part of the process involves exporting that doc to plaintext and sending on to another service.
I handle that part in a web service of my own using the Drive API.

My add-on sends its OAuth2 access token to my service (implicit flow), and the url of the Google Doc.
(You might say naughty naughty for not using credentials flow, but guess what, the Google Picker docs recommend doing the exact same thing so the picker doesn't show a second consent screen. It's the same idea for my app. I don't want to make them consent for the same thing twice. And I don't want to access their doc when the user is not present.)

The trouble is that my web app cannot access the Google Doc.

The reason is because the /auth/drive.file scope only grants my AppsScript app access to a doc if:
1. My app created the doc; or
2. The user selected my app in the Google File Picker.

Neither of these options make sense to my use case, or frankly, to any use case where a user wants to open a Google Docs Editor Add-on for just the currently open file.

How could I get my app to work with the /auth/drive.file scope, only one consent screen, and no file picker?

1 1 532
1 REPLY 1

Found any solution? I am having the same issue. I got to know that i can use Google picker. I implemented it in the google classroom addon and was able to get the metadata of the files selected from the drive using picker. I want to download the file in the backend, and I think that picking a file using picker will still not allow me to download the file in the backend. Is there any way to download the file in backend with drive.file scope?

Top Labels in this Space