Reputation: 131
I have two Google Apps projects. I'm not sure if this is relevant, but one is attached to a document in the root of My Drive and the other to a document in a shared drive where I am a Manager.
I would like to be able to list these Apps projects using the Drive API and ultimately export them.
I followed the "List existing projects" example at https://developers.google.com/apps-script/guides/import-export, but when I run the request on my own account, it returns an empty "items" array and no error.
I'm testing using the OAuth 2.0 Playground (https://developers.google.com/oauthplayground) as follows;
The result is always an empty items array, e.g.:
{
"incompleteSearch": false,
"items": [],
"kind": "drive#fileList",
"etag": "\"skD00[redacted]\"",
"selfLink": "https://www.googleapis.com/drive/v2/files?q=mimeType%3D'application/vnd.google-apps.script'+and+'me'+in+owners"
}
And, if I change the requested mimeType (e.g. https://www.googleapis.com/drive/v2/files?q=mimeType%3D'application%2Fvnd.google-apps.document'+and+'me'+in+owners) then I see the files as expected.
Finally, in the OAuth 2.0 Playground, I tried adding the additional scope https://www.googleapis.com/auth/script.projects.readonly, but when I click "Authorize APIs", I get
This app is blocked
This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access.
I then tried returning to the PHP project where I first encountered the missing Apps project files in the listing of my Drive directory, and added the /auth/script.projects.readonly scope to my service account as well as to the requested scope in my app's OAuth 2.0 configuration. I received no notification about the app being blocked, but the script files continue to not be returned in the file list, so it seems adding this additional scope doesn't help.
UPDATE: Thanks to the related issue mentioned by Tanaike (https://issuetracker.google.com/issues/111149037), I determined that the problem is limited to container-bound Apps (those created in a document, sheet, etc.). Standalone Apps (those with "me" as the container) are listed by the Drive files.list API as expected.
Upvotes: 0
Views: 356
Reputation: 131
This behavior is actually documented at https://developers.google.com/apps-script/guides/import-export:
Only standalone scripts can be imported or exported. Container-bound scripts cannot be accessed through the Google Drive REST API.
Upvotes: 1