DriveApp.getFolderById会导致“您没有权限"错误 [英] DriveApp.getFolderById results in "you do not have permission" error

查看:79
本文介绍了DriveApp.getFolderById会导致“您没有权限"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 getFolderById 函数方面遇到问题.我是该文件夹的所有者.具体调用如下.

I am having issues with the getFolderById function. I am the owner of the folder in question. The specific call is as follows.

var folder = DriveApp.getFolderById('string_id_of_my_folder');

我正在函数内部传递文件夹ID的长字符串.我在编辑器中运行了该函数,以确保权限已打开-并且没有收到任何错误.

I am passing the long string of the ID of the folder inside the function. I ran the function inside the editor to make sure permissions have been turned on - and I'm not getting any errors.

但是,当我尝试在电子表格中运行该函数时,收到以下错误消息:您无权调用getFolderById" .

But when I try to run the function inside the spreadsheet, I get the following error message: "You do not have permission to call getFolderById".

我在做什么错了?

推荐答案

此处的问题是自定义函数&简单的触发器以有限的权限运行:您不能执行需要用户凭据的操作,例如从另一个文件读取.这些限制在此处自定义功能中阐明&此处为简单触发器.

The issue here is that custom functions & simple triggers run with limited permissions: you can't perform actions that require user credentials, like reading from another file. These limitations are spelled out here for custom functions & here for simple triggers.

可安装的触发器没有此限制.因此,如果您需要在打开当前文件时或从独立脚本访问另一个文件,则需要安装 Open 触发器.此处是Google的文档.

Installable triggers don't have this limitation. So if you needed to access another when you open your current file or from a standalone script, you'll need to install an Open trigger. Here's Google's documentation.

这篇关于DriveApp.getFolderById会导致“您没有权限"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆