使用LIMITED身份验证的附加组件无法打开侧边栏

时间:2017-11-27 18:15:33

标签: google-apps-script google-oauth google-docs

我有一个Google文档插件,可以在文档打开后立即打开侧边栏。当然,这需要在文档中安装和启用加载项。

我看到,自从一周以来,侧栏自动打开功能在我们的用例中非常有用,不再有效。

在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()应该成功,根据addon authorization lifecyle(只需查看表格中的专栏有限公司)。

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

这里的记录是一个代码片段:

/**
 * 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
    }
}

2 个答案:

答案 0 :(得分:1)

昨天我们发现了与你Yves完全相同的问题。 但是对于我们来说,它发生在Google表格插件中。

我在Google上创建了一个问题:https://issuetracker.google.com/issues/69824548

请注明并发表评论,以便尽快收听!

答案 1 :(得分:0)

来自https://developers.google.com/gsuite/add-ons/concepts/editor-auth-lifecycle

  

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

相关问题