【问题标题】:How to fix error "Exception: You do not have permission to call DriveApp.getFiles. Required permissions: "如何修复错误“异常:您无权调用 DriveApp.getFiles。所需权限:”
【发布时间】:2019-08-14 09:23:15
【问题描述】:

问题是错误“异常:您没有调用 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);
  }
}

我希望我在谷歌驱动器上的所有文件都将选中“禁用选项以供评论者和查看者下载、打印和复制”。

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    现在明白了,我将 isShareableByEditors() 更改为 setShareableByEditors()。

    更正:

    function test(){
      var files = DriveApp.getFiles();
      while (files.hasNext()) {
        var file = files.next();
        file.setShareableByEditors(false);
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-30
      • 2017-01-15
      • 2011-06-02
      • 2013-02-24
      • 2018-05-24
      • 2019-08-11
      • 2021-03-11
      • 1970-01-01
      相关资源
      最近更新 更多