您无权执行该操作 [英] You do not have permission to perform that action
问题描述
我有一个时间触发的脚本,该脚本会定期从外部来源检索内容,并使用它来更新Google网站页面. 根据此,该脚本应在我的帐户下运行,它具有对该Google网站页面的完整评估(通过手动编辑进行了测试). 但是当我运行脚本时,我得到了
I have a time-triggered script that periodically retrieves content from an external source and updates a Google sites page with it. According to this, the script should be running under my account, which has full assess to that Google site page (tested by manually editing it). But when I run the script, I get the
您无权执行该操作.
You do not have permission to perform that action.
如果可以手动编辑页面,为什么在运行脚本时没有该权限?
Why do I not have that permission when running the script, if I can edit the page manually?
这是(通用的)脚本功能:
Here is the (generalized) script function:
function updatePage() {
var site = 'https://sites.google.com/a/mydomain.com/myhome/mypagegroup/mypage';
var pageName = '/mypagegroup/mypage';
var site = SitesApp.getSiteByUrl(site);
var page = site.getChildByName(pageName); //works fine
Logger.log('page: ' + page.getTitle()); //displays correct page title
var html = '<p>'; //in actual script, I get html from external source
Logger.log('html: ' + html);
page.setHtmlContent(html); //this is where the error is generated ("You do not have permission to perform that action")
};
推荐答案
在脚本编辑器中,您是否从下拉列表中选择了函数名称,然后单击运行"图标?
In the script editor, did you choose the function name from the drop down list, and click the run icon?
首次使用这种方式运行时,将显示一个弹出窗口,指出需要授权.您必须授权修改站点.如果还没有完成,则会出现错误.
The first time you run it this way, a pop up will display, stating that authorization is needed. You must give authorization to modify sites. If that hasn't been done, you'll get an error.
授权网站
在授权脚本后,我运行了您的代码,并且可以正常工作.
I ran your code, after authorizing the script, and it worked.
您可以进入您的帐户,并检查您已获得许可的项目.您需要选择帐户",然后在帐户设置"窗口的安全检查"部分中单击入门".
You can go into your account, and check what projects you have given permissions to. You need to choose "Account", and then click "Get Started" in the Security checkup section of the Account settings window.
这篇关于您无权执行该操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!