简体   繁体   English

Google Apps脚本访问文件夹的权限

[英]Google apps script permission to access a folder

This simple code works in a standalone script and also in a script bound to a google sheet if i run directly the function, but get a permission error when i run it opening the sheet. 如果我直接运行该函数,则此简单代码可在独立脚本中运行,也可在绑定到Google工作表的脚本中工作,但是在我打开工作表运行它时会出现权限错误。 Where is the problem? 问题出在哪儿?

function onOpen() {
  jsondir = DriveApp.getFolderById("XXXXXXXXXXXXXXXXXXXXXXXXXXXX")
  Logger.log(jsondir)
}

In the case of use of method (DriveApp) which is required the authorization, the function has to be installed as a trigger. 在使用需要授权的方法(DriveApp)的情况下,该功能必须作为触发器安装。 How to install the trigger is as follows. 触发器的安装方法如下。 The detail information is here . 详细信息在这里

  • On the script editor. 在脚本编辑器上。
    • Edit -> Current project's triggers 编辑->当前项目的触发器
    • Click "No triggers set up. Click here to add one now." 单击“未设置任何触发器。单击此处立即添加一个。”
    • At "Run", select "onOpen" 在“运行”中,选择“ onOpen”
    • At Events, select "From spreadsheet" and "On open" 在活动中,选择“来自电子表格”和“打开时”
    • Push "Save" button. 按“保存”按钮。

If I misunderstand your question, I'm sorry. 如果我误解了您的问题,对不起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM