其他用户在 GAS web 应用程序中触发执行失败

Trigger execution failure in GAS web app by other users

我制作了一个网络应用程序来将我的 google 驱动器文件夹复制到其他用户的驱动器。为了解决执行时间超出错误,我试图为一个函数创建一个触发器,并使该函数在几分钟后启动。此 Web 应用程序将由其他用户执行,因此我将“执行身份”设置为“访问该 Web 应用程序的用户”,将“谁有权访问”设置为“拥有 Google 帐户的任何人”。

当我(此 Web 应用程序的创建者)运行 Web 应用程序时,它按预期工作,但在其他用户执行时失败。我看不到此失败的任何日志,因为在应用程序创建者和用户的 Apps 脚本仪表板的“我的执行”中没有可用信息。

我尝试将执行流程记录到日志 sheet 中,但执行一开始就失败了,因为无法记录执行的任何内容。

如何让其他用户运行获得他们的许可触发功能?

下面是测试触发器和其他用户执行的示例代码。 (我删除了缓存的所有代码,因为它与此问题相关)

Code.gs

const deleteTrigger = (functionName) => {
  ScriptApp.getProjectTriggers().forEach((t) => {
    ScriptApp.deleteTrigger(t);
  });
};


function doGet(e) {
  Logger.log(e.parameter);
  return HtmlService.createHtmlOutputFromFile('index');
}

function myFunction() {
  ScriptApp.newTrigger('reStart')
    .timeBased()
    .after(3 * 60 * 1000)
    .create();
}

function reStart() {
  deleteTrigger();
}

index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
  <div>
  <button id="myFunction">myFunction, make trigger</button><br>
  <button id="reStart">reStart by manual</button><br>
  <button id="deleteTrigger">Delete Trigger</button>
  
  <script>
  document.getElementById('myFunction').addEventListener('click', function() {
    google.script.run.myFunction();
  });
  document.getElementById('reStart').addEventListener('click', function() {
    google.script.run.reStart();
  });
  document.getElementById('deleteTrigger').addEventListener('click', function() {
    google.script.run.deleteTrigger();
  });
  </script>
  </body>
</html>

在花费了无用的时间和精力之后,我发现 基于时间的触发器在 V8 中不起作用。

查看 https://groups.google.com/g/google-apps-script-community/c/VTPmr05Gs8k/m/vdH7jWTfBwAJ 了解详情。

如果问题仅在 V8 运行时出现,您可以在 Google 的问题跟踪器上创建问题,在 apps script component