joon
joon

Reputation: 870

Cannot create files using auth/drive.file OAuth scope

I am working on a Google Sheets Addon written in Apps Script. I have been recommended by the review team to use the https://www.googleapis.com/auth/drive.file scope but I can't find any way to make it generate a file.

  var file = DriveApp.createFile("dummy.txt", "beep boop");

Gives me this error:

Specified permissions are not sufficient to call DriveApp.createFile. Required permissions: https://www.googleapis.com/auth/drive

However, according to Google, it sounds like drive.file should be able to do this:

Create new Drive files, or modify existing files, that you open with an app or that the user shares with an app while using the Google Picker API or the app's file picker.

But I cannot find any example code or reference to what is required to make this possible.


other things I've tried or discovered:

According to answers in this post, there are alternative ways,

two other ways. 1. Advanced Drive service: developers.google.com/apps-script/advanced/drive If that fails, 2. Use UrlFetchApp to directly access the Drive API: github.com/googleworkspace/apps-script-oauth2/tree/main/samples/…

source: How to use "https://www.googleapis.com/auth/drive.file" to minimize permissions?

When I try to use UrlFetchApp I get the following:

Error in fetchUrlAndCreateFile: Exception: Specified permissions are not sufficient to call UrlFetchApp.fetch. Required permissions: https://www.googleapis.com/auth/script.external_request

This scope does not appear in the Google Cloud OAuth Consent Screen "Add scope" menu.

According to wording in the review emails using the Google Picker API should help here. All of my tests have happened inside of the successful callback of a Google Picker API set to return the folderId, but I can't get any of these methods to actually create a new file anywhere on my drive.

Upvotes: 0

Views: 36

Answers (1)

TheMaster
TheMaster

Reputation: 50731

This scope does not appear in the Google Cloud OAuth Consent Screen "Add scope" menu.

You should still be able to add the scope manually.

Upvotes: 1

Related Questions