google-apps-script - 如何修复错误“异常:您无权调用 DriveApp.getFiles。所需权限:”
问题描述
问题是错误“异常:您无权调用 DriveApp.getFiles。所需权限:”在“oauthScopes”时显示:[“ https://www.googleapis.com/auth/spreadsheets.readonly ”、“ https ://www.googleapis.com/auth/userinfo.email "] 放在 appscript.js 中。但是当我删除这些 oautScope 时,错误将显示“异常:参数与 isShareableByEditors 的方法签名不匹配。(第 15 行,文件“代码”)”。我正在制作我的所有文件以检查“禁用评论者和查看者的下载、打印和复制选项”。我已经启用了驱动 API。
function test(){
var files = DriveApp.getFiles();
while (files.hasNext()) {
var file = files.next();
file.isShareableByEditors(false);
}
}
我希望我在谷歌驱动器上的所有文件都将选中“禁用评论者和查看者下载、打印和复制的选项”。
解决方案
现在明白了,我将 isShareableByEditors() 更改为 setShareableByEditors()。
更正:
function test(){
var files = DriveApp.getFiles();
while (files.hasNext()) {
var file = files.next();
file.setShareableByEditors(false);
}
}
推荐阅读
- regex - 时间复杂度提升正则表达式
- c++ - 错误:变量或字段“回文”在 C++ 中声明为 void
- python - 返回错误的类型,如何解决?
- apache - 根据 oracle http 服务器上的 cookie 更改 WebLogicHost 或 Location 部分
- angular - 在 Angular 中使用 Parallax.js 会引发错误“无法读取属性 'getAttribute' of null”
- flutter - 将 Flutter 项目迁移到 AndroidX 后,我的 AndroidManifest.xml 出现 13 个错误,需要帮助
- javascript - Youtube Data API v3 请求发送了两次
- java - 如何重置 radio_button.setButtonDrawable(null)
- c# - 在 linq join 中使用 DbQuery -> Entity Framework Core
- react-native - react-native-scratch-card(仅限 Android)给出“设备:(35:287)不变违规”