Triggers G应用程序脚本工作表反复请求授权,尽管已多次授予授权(时间驱动触发器)
从2018年6月21日凌晨1:59,在一份背景为脚本的谷歌电子表格上,我反复要求授权,并发送“谷歌应用程序脚本失败摘要”电子邮件,内容如下 启动功能错误消息触发器结束 18年6月21日凌晨3:54执行该操作需要ScanGmail授权。基于时间的2018年6月21日凌晨3:54 我已经多次使用'function auth(){}'再次授予授权(似乎每次我注销或计算机进入睡眠模式时都必须这样做) 我还实现了授权脚本,但没有发送授予授权的电子邮件,只有应用程序脚本错误通知Triggers G应用程序脚本工作表反复请求授权,尽管已多次授予授权(时间驱动触发器),triggers,authorization,spreadsheet,Triggers,Authorization,Spreadsheet,从2018年6月21日凌晨1:59,在一份背景为脚本的谷歌电子表格上,我反复要求授权,并发送“谷歌应用程序脚本失败摘要”电子邮件,内容如下 启动功能错误消息触发器结束 18年6月21日凌晨3:54执行该操作需要ScanGmail授权。基于时间的2018年6月21日凌晨3:54 我已经多次使用'function auth(){}'再次授予授权(似乎每次我注销或计算机进入睡眠模式时都必须这样做) 我还实现了授权脚本,但没有发送授予授权的电子邮件,只有应用程序脚本错误通知 var addonTitle
var addonTitle = 'PRE_Inv_Conf';
var props = PropertiesService.getDocumentProperties();
var authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);
// Check if the actions of the trigger requires authorization that has not
// been granted yet; if so, warn the user via email. This check is required
// when using triggers with add-ons to maintain functional triggers.
if (authInfo.getAuthorizationStatus() ==
ScriptApp.AuthorizationStatus.REQUIRED) {
// Re-authorization is required. In this case, the user needs to be alerted
// that they need to re-authorize; the normal trigger action is not
// conducted, since it requires authorization first. Send at most one
// "Authorization Required" email per day to avoid spamming users.
var lastAuthEmailDate = props.getProperty('lastAuthEmailDate');
var today = new Date().toDateString();
if (lastAuthEmailDate != today) {
if (MailApp.getRemainingDailyQuota() > 0) {
var html = HtmlService.createTemplateFromFile('AuthorizationEmail');
html.url = authInfo.getAuthorizationUrl();
html.addonTitle = addonTitle;
var message = html.evaluate();
MailApp.sendEmail(Session.getEffectiveUser().getEmail(),
'Authorization Required',
message.getContent(), {
name: addonTitle,
htmlBody: message.getContent()
}
);
}
props.setProperty('lastAuthEmailDate', today);
}
} else {
在CET时间6/21/18凌晨1:59,谷歌方面是否发生了变化,或者出现了什么问题,有没有办法避免这种行为?这似乎是一个谷歌错误,因为在受影响的电子表格或相关的谷歌账户上,我方没有发生任何变化。不确定它是否出现,因为我运行多个谷歌帐户,但这是我的解决方案