Daniel Bandeira
Daniel Bandeira

Reputation: 378

Changing DriveApp.Permission of a file/folder

I am spending hours (literally) trying to find a way to change the DriveApp.Permission of my script (for web App).

Actually, its value is VIEW, not allowing me to create folders, files or edit them (read only).

The script is configured to run as "me", accessible for anyone.

I have checked the owner of the folder ( FOLDER.getOwner().getEmail(); ) and owner of the user/session ( Session.getActiveUser().getEmail() ).

Not surprisingly, they've returned the same value. I have read THIS, but without success in retrieving any useful information.

I think, the problem is around the DriverApp.Permission value.

I was brief as a possible, I think. Could someone help me?

To put it clear: the script, the driver, etc., all of them belongs to me ( \o/ ).

Example:

DriveApp.getRootFolder().getFoldersByName( "ExistingFolder" ).next().createFile( "No_authorized_it_will_not_be_created_and_will_trigger_a_exepction" , "Some TEXT" );

Google GET response (translated/approximated)

Exception: You don't have permission to call DriveApp.Folder.createFile. You need to have permissions :https://www.googleapis.com/auth/drive (line 135, file "InternalDriver")

Upvotes: 1

Views: 906

Answers (1)

Daniel Bandeira
Daniel Bandeira

Reputation: 378

With support of @Copper and suggestion of @TheMaster, my solution:

Add this JSON object to the manifest

"oauthScopes": ["https://www.googleapis.com/auth/documents", "https://www.googleapis.com/auth/drive"]

Create a new version of the project, and try it again.

I have removed the actual permission related to project before deploy a new version.

I'm not sure whether "https://www.googleapis.com/auth/documents" path is necessary for simple creation or edition of folders/files. The other path string is certainly needed.

Upvotes: 1

Related Questions