admin管理员组文章数量:1336437
I am writing a JavaScript tool in Google Apps Script to check some properties of documents, like "are all links valid", "are permissions set correctly", and so on. I am using the API documented in to look up files by ID, check their permissions, locate them in Google Drive etc., but I found that "Shared Drives" don't work very nicely with that API.
For example,
- for the root folder of a Shared Drive,
Folder.getName()
only returns "Drive" rather than the Drive's name, - even though
[email protected]
is a "Manager" of the Shared Drive,folder.getAccess('[email protected]')
is NONE andfolder.getViewers()
is empty, - some folders in Shared Drives are not (always) included in the
DriveApp.getFolders()
iterator.
In particular the second point is a blocker for me now, but what am I missing here? Is there some other API I should be using, or is it simply a bug that I should report? Is there some documentation of what functionality of the Drive
API I can and cannot use with Shared Drives?
I am writing a JavaScript tool in Google Apps Script to check some properties of documents, like "are all links valid", "are permissions set correctly", and so on. I am using the API documented in https://developers.google./apps-script/reference/drive/drive-app to look up files by ID, check their permissions, locate them in Google Drive etc., but I found that "Shared Drives" don't work very nicely with that API.
For example,
- for the root folder of a Shared Drive,
Folder.getName()
only returns "Drive" rather than the Drive's name, - even though
[email protected]
is a "Manager" of the Shared Drive,folder.getAccess('[email protected]')
is NONE andfolder.getViewers()
is empty, - some folders in Shared Drives are not (always) included in the
DriveApp.getFolders()
iterator.
In particular the second point is a blocker for me now, but what am I missing here? Is there some other API I should be using, or is it simply a bug that I should report? Is there some documentation of what functionality of the Drive
API I can and cannot use with Shared Drives?
- 1 Does this answer your question? Accessing Files and Folders in Team Drive – Wicket Commented Jun 16, 2020 at 14:48
- 2 It is related, but I think the main point I was missing is that (1) yes, I cannot work with Team Drives using the DriveApp API, and (2) I can use the Drive API v2 from within Google Apps Script scripts, which both seem to be already known to the user asking the question in your link. So I think in that regard the question is not exactly a duplicate, and the answer provided by ziganotschka below provided important information to me. – tgpfeiffer Commented Jun 17, 2020 at 1:13
1 Answer
Reset to default 6Use the Advanced Drive Service instead of DriveApp
- Indeed, shared drives are not supported by
DriveApp
which has a limited scope - But if you enable the
Advanced Drive Service
, yuo will be able to use in Apps Script all methods of the Drive API v2 which support shared drives
Sample:
function myFunction() {
var sharedDriveName = Drive.Drives.get("XXXXXXXXXXXXXXXXXXX").name;
//it is important to specify that the folder is located on a shared drive with {"supportsAllDrives": true}
var folderOnDriveName = Drive.Files.get("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",{"supportsAllDrives": true}).title;
var folderPermissions = Drive.Permissions.list("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",{"supportsAllDrives": true});
}
本文标签: javascriptquotShared Drivequot support in Google Apps ScriptStack Overflow
版权声明:本文标题:javascript - "Shared Drive" support in Google Apps Script - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742309137a2450512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论