Domain SuperAdmin using AppScript getting error: API call to drive.teamdrives.insert failed with error: Insufficient permissions for this file
Domain SuperAdmin using AppScript getting error: API call to drive.teamdrives.insert failed with error: Insufficient permissions for this file
我正在开发需要创建新 Google TeamDrive 的 Google 应用程序脚本。我是我所在域的超级管理员,当我尝试执行代码(按照 App Script 代码完成的建议编写)时,出现错误:
API call to drive.teamdrives.insert failed with error: Insufficient permissions for this file (line 288, file "Code")
我一直难以找到严格处理 App 脚本的文档,因此我正在尝试调整此处找到的 API 方法:https://developers.google.com/drive/api/v3/reference/drives/create
显然,我没有使用直接的 http 调用,而是使用 App 脚本 API,如下面的代码所示。另外,我注意到 API v3 使用了 create 方法,而不是 v2 中使用的 insert 方法。应用程序脚本似乎仍在使用插入方法。用 create 替换 insert 会产生一条错误消息,指示基础 API 版本为 2:
TypeError: Cannot find function create in object AdvancedServiceIdentifier{name=drive, version=v2}.
v2中的insert方法与v3中的create非常相似:
https://developers.google.com/drive/api/v2/reference/drives/insert
我在尝试检索现有驱动器的权限时遇到了类似的错误,解决方案是在请求中传递 "supportsAllDrives=true" 参数(使用 API 调用的可选参数参数)。不幸的是,"insert" 方法没有我可以用来传递可选参数的参数——资源表示和请求 ID 是 "insert" 方法的唯一参数。
我的代码:
function createSharedDrive() {
var resource = {
name: "TestDriveChrisD6"
};
var drive = Drive.Teamdrives.insert(resource, "testRequestId_TestDriveChrisD6");
Logger.log(JSON.stringify(drive)); // to see the result if it works eventually
}
我希望这个 API 调用会导致包含驱动器表示的响应,但我收到错误消息:
API call to drive.teamdrives.insert failed with error: Insufficient permissions for this file (line 288, file "Code")
错误消息中的行号只是我的源代码行号,其中包含代码:
var drive = Drive.Teamdrives.insert(resource, "testRequestId_TestDriveChrisD6");
我做错了什么?我应该通过直接请求调用http方法吗?
我的问题已经解决如下:
- 前往管理控制台 -> 应用 -> G Suite -> 云端硬盘和文档 -> 共享设置
- 在我的域中,"Shared drive creation" 部分的设置 "Prevent users in <domain name> from creating new shared drives" 在全局域设置中处于开启状态,对于管理员组织单位处于关闭(覆盖)状态。原来我的用户在管理员组中,但不在管理员组织单位中。将我的用户移至管理员 OU 解决了问题。
我正在开发需要创建新 Google TeamDrive 的 Google 应用程序脚本。我是我所在域的超级管理员,当我尝试执行代码(按照 App Script 代码完成的建议编写)时,出现错误:
API call to drive.teamdrives.insert failed with error: Insufficient permissions for this file (line 288, file "Code")
我一直难以找到严格处理 App 脚本的文档,因此我正在尝试调整此处找到的 API 方法:https://developers.google.com/drive/api/v3/reference/drives/create
显然,我没有使用直接的 http 调用,而是使用 App 脚本 API,如下面的代码所示。另外,我注意到 API v3 使用了 create 方法,而不是 v2 中使用的 insert 方法。应用程序脚本似乎仍在使用插入方法。用 create 替换 insert 会产生一条错误消息,指示基础 API 版本为 2:
TypeError: Cannot find function create in object AdvancedServiceIdentifier{name=drive, version=v2}.
v2中的insert方法与v3中的create非常相似: https://developers.google.com/drive/api/v2/reference/drives/insert
我在尝试检索现有驱动器的权限时遇到了类似的错误,解决方案是在请求中传递 "supportsAllDrives=true" 参数(使用 API 调用的可选参数参数)。不幸的是,"insert" 方法没有我可以用来传递可选参数的参数——资源表示和请求 ID 是 "insert" 方法的唯一参数。
我的代码:
function createSharedDrive() {
var resource = {
name: "TestDriveChrisD6"
};
var drive = Drive.Teamdrives.insert(resource, "testRequestId_TestDriveChrisD6");
Logger.log(JSON.stringify(drive)); // to see the result if it works eventually
}
我希望这个 API 调用会导致包含驱动器表示的响应,但我收到错误消息:
API call to drive.teamdrives.insert failed with error: Insufficient permissions for this file (line 288, file "Code")
错误消息中的行号只是我的源代码行号,其中包含代码:
var drive = Drive.Teamdrives.insert(resource, "testRequestId_TestDriveChrisD6");
我做错了什么?我应该通过直接请求调用http方法吗?
我的问题已经解决如下:
- 前往管理控制台 -> 应用 -> G Suite -> 云端硬盘和文档 -> 共享设置
- 在我的域中,"Shared drive creation" 部分的设置 "Prevent users in <domain name> from creating new shared drives" 在全局域设置中处于开启状态,对于管理员组织单位处于关闭(覆盖)状态。原来我的用户在管理员组中,但不在管理员组织单位中。将我的用户移至管理员 OU 解决了问题。