从WebApp创建基于时间的触发器 [英] Creating time-based trigger from WebApp

查看:107
本文介绍了从WebApp创建基于时间的触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从以Google Web Apps发布的Google Apps脚本创建基于时间的触发器。

更新:此WebApp应作为访问它的用户运行,而不是作为Apps脚本所有者。



当我尝试访问ScriptApp服务时,前端出现错误:


执行该操作需要授权。

示例代码重现这一点将是:

pre $函数doGet(请求){
ScriptApp.newTrigger('test' );
返回ContentService.createTextOutput(OK);
};

function test(){
// noop
}

这是不可能的吗?是否有可能以某种方式自动添加一个触发器,该触发器在给予授权的用户的基础上根据时间运行方法?凭证是您的网络应用程序运行?作为运行该应用程序的用户或作为您自己。
从错误中,它看起来像在作者的凭据下运行。
在这种情况下,您应该在分发URL之前明确授权应用程序。为此,请打开脚本编辑器并选择任何函数,然后尝试使用脚本编辑器中的play按钮运行该函数。系统会要求您提供权限,然后您可以使用Ui应用程序

I am trying to create a time-based trigger from a Google Apps Script published as a WebApp.

Update: this WebApp shall be run as the user accessing it, not as the Apps Script owner.

Whenver I even try to access the ScriptApp services, I get an error in the frontend:

Authorization is required to perform that action.

Sample code to reproduce this would be:

function doGet(request) {
  ScriptApp.newTrigger('test');
  return ContentService.createTextOutput("OK");
};

function test() {
  // noop
}

Is this something that is not possible? Is it possible to somehow automatically add a trigger that runs a method based on time with the user giving the authorization?

解决方案

Under what credentials is your web app run ? As the user running the app or as yourself. From the error, it looks like it is run under the author's credentials. In this case, you should authorize the application explicitly before you can distribute the URL. To do so, open the script editor and choose any function and try to run the function using the little 'play' button in the script editor. You'll be asked to provide permissions after which you can use the Ui App

这篇关于从WebApp创建基于时间的触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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