Search code examples
google-apps-scriptgoogle-apps-script-addon

File creation and download, Drive scopes, and publishing editor add-on


I'm working on an Forms add-on which would allow you to export survey response data and/or save it to user's Drive. Is there no way to do this other than allowing full Drive access through the most extensive scope?

And about publishing editor add-on, how does one go about with it? I'm unable to get it to G-Suite marketplace, and the original unlisted version was on Chrome Webstore. (which is now unavailable)

I tried to test it with "Integrate With Google" via the G-Suite Marketplace API, but nothing shows up when testing. I don't know why, since the add-on works as expected via "Test as extension" from Google Apps Script editor. And the "waiting for review" has been taking ages. Is there any way to know the status of it?

EDIT: It seems like only Drive API can be used with custom scope (after enabling it), but DriveApp always requires full-access scope. And the functions that fetch files from Drive ONLY give out those that the script has access to (created or opened with) if you're using drive.file scope. ...the publishing part is still a mess though.


Solution

  • Regarding scopes and using Drive through Apps Script, there is two things that are needed to know.

    1) DriveApp class that is readily provided in Apps Script, always requires full read-write access to user's Drive. This apparently can't be changed.

    2) Drive API (v2) under "Advanced Google Services" allows usage of all available Drive scopes. This, however, needs to be enabled separately.

    Another thing: drive.file scope allows you to only access files and folders in user's Drive that have been opened or created with specific script. This includes queries, so you only get what you can access. No need to check permissions separately.