Ehsan Amini
Ehsan Amini

Reputation: 169

How to access the appDataFolder with the DriveApp or the Drive Service of app script?

I was thinking this might work:

var ADF = DriveApp.getRootFolder().getFoldersByName('appDataFolder');

I also tried:

var ADF = Drive.Children.list('appfolder');

But I get: "The current scope does not allow use of the appdata folder"

The Drive Service v.2 is enabled both in the script resources and on the Developer's console. Version 3.0 is not listed is not available in the Resources dialogue box.

Is this folder accessible to stand-alone app script webapps at all?

I would like to store my webapp data files there, rather than creating a visible folder on the user's root.

Upvotes: 4

Views: 2529

Answers (2)

Chisom Maxwell
Chisom Maxwell

Reputation: 197

During Google sign in, add the app data scope to your list of sign in scopes.

Upvotes: 0

Mr.Rebot
Mr.Rebot

Reputation: 6791

Is this folder accessible to stand-alone app script webapps at all?

It is possible, using the right scope to access it.

Get authorization to use the Application Data folder

  • To be able to use your Application Data folder, request access to the following scope:
https://www.googleapis.com/auth/drive.appdata

How To's

Check Scopes in project

  • File -> Project Properties -> Scopes enter image description here

To add scopes, you must create a OAuth2 for Apps Script, here is a github sample of a Google Apps Script library to access the Appfolder in Google Drive.

Switch On the Google Advance Service

  • Resources -> Advance Google Services.... enter image description here

Hope this helps.

Upvotes: 1

Related Questions