Google apps script 授权有限的加载项无法打开侧栏

Google apps script 授权有限的加载项无法打开侧栏,google-apps-script,google-oauth,google-docs,google-apps-script-addon,Google Apps Script,Google Oauth,Google Docs,Google Apps Script Addon,我有一个GoogleDocs插件,它被编程为在文档打开后立即打开侧栏。当然,这需要在文档中安装并启用附加组件 我看到,从一个星期以来,边栏自动打开特性(在我们的用例中非常有用)不再起作用 在StackDriver日志中,我看到以下报告: onOpen(): {authMode=LIMITED, source=Document, user=} publi-2.0.72-2017-11-27-18-57 [this is the publication version

我有一个GoogleDocs插件,它被编程为在文档打开后立即打开侧栏。当然,这需要在文档中安装并启用附加组件

我看到,从一个星期以来,边栏自动打开特性(在我们的用例中非常有用)不再起作用

在StackDriver日志中,我看到以下报告:

onOpen():  {authMode=LIMITED, source=Document, user=} 
publi-2.0.72-2017-11-27-18-57               [this is the publication version tag]
2017-11-27T18:02:50.126Z : show menu 
2017-11-27T18:02:50.180Z : show sidebar 
Error showing sidebar  Exception: You do not have permission to call showSidebar 
2017-11-27T18:02:50.283Z : end onOpen 
很明显,加载项处于受限模式,showSidebar()应该会成功,根据(只需查看表中的LIMITED列)

-->我怀疑最近引入了错误或新的安全限制。

下面是一段代码片段:

/**
 * Basic setup. At the beginning:
 * 1. Add a "Add-ons" menu item.
 * 2. Display the doxMaster sidebar.
 */
function onOpen(e) {
    console.log("onOpen(): ",e)
    console.log(addonversion);
    doServerLog("show menu");
    showMenu();
    doServerLog("show sidebar");
    showSidebar();
    doServerLog("end onOpen");
}

/**
 * Creates the Add-ons menu at the google drive panel.
 */
function showMenu() {
    DocumentApp.getUi().createAddonMenu()
        .addItem(translate("sidebarMenu"), showSidebar.name)
        .addItem(translate("joinFollowingParagraph"), insertJoinFollowingParaSymbol.name)
        .addItem(translate("importDocument"), importDocument.name)
        .addItem(translate("about"), about.name)
        .addToUi();

}

/**
 * Creates a doxMaster Add-on Sidebar.
 */
function showSidebar() {
    try {
        var htmlTemplate = HtmlService.createTemplateFromFile('sidebar');
        var html = htmlTemplate.evaluate().setTitle(translate("appTitle"));
        DocumentApp.getUi().showSidebar(html);
    }
    catch (e) {
        console.log("Error showing sidebar ", e); // Add-on has not been enabled in this document
    }
}

我重新测试,我发现:

  • 安装加载项时,模式设置为“完全”
  • 然后打开文档模式设置为“无”
  • 打开加载项后,关闭文档,然后重新打开,模式受到限制
这与预期的生命周期一致,除了:

  • createTemplate在受限模式下失败
  • 在受限模式下,事件的{user=}没有值:
08:22:36.457 onOpen():{authMode=LIMITED,source=Document,user=}


我认为用户权限有些丢失。

昨天我们注意到了与您完全相同的问题。 然而,对我们来说,它发生在谷歌表单插件中

我在谷歌上发表了一篇文章:

请明星和评论,使它很快被拿起

来自

注意:在AuthMode.LIMITED中执行时,加载项无法打开侧栏或对话框。您可以使用菜单项打开侧栏和对话框,因为它们在AuthMode.FULL中运行

来自(来自谷歌应用程序脚本问题跟踪程序的问题)

状态:无法修复(预期行为)很抱歉延迟回复 在这里在与工程团队进行了多次交谈后 决定无法支持打开UI元素(侧栏、对话框) 在onOpen和onEdit中。授权生命周期文档已经发布 已更新,以明确您只能在中添加菜单项 这些模式:

我们理解这会影响您可能的用户体验 请提供,我们为变更的突然性道歉


经过更多的测试后,我发现即使是sidebar.html文件被简化为一个简单的Hello World

的插件,也会请求新的权限“在Google应用程序的提示和侧栏中显示和运行第三方web内容”。->这很奇怪,因为加载项中没有此类内容。引用的问题与标记为“不会修复”的问题合并@SandyGood有任何更新吗?因为,如果您尝试使用Google文档模板库中的某些第三方模板(例如销售类别中的Pandadoc模板),此附加组件可以自动启动。@aaryan请参见