[英]add-on with LIMITED auth cannot open sidebar
我有一个 Google docs 插件,它被编程为在文档打开后立即打开侧边栏。 当然,这需要在文档中安装并启用附加组件。
我看到,自一周以来,在我们的用例中非常有用的侧边栏自动打开功能不再有效。
在 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
很明显,根据插件授权生命周期,插件处于 LIMITED 模式并且 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
}
}
昨天我们注意到了与您 Yves 完全相同的问题。 但是对我们来说,它出现在 Google Sheets 插件中。
我在谷歌创建了一个问题: https : //issuetracker.google.com/issues/69824548
请加星标并发表评论,以便它尽快被收录!
我重新测试,我看到:
这与预期的生命周期一致,除了:
08:22:36.457 onOpen(): {authMode=LIMITED, source=Document, user=}
我认为用户权限有些丢失。
来自https://developers.google.com/gsuite/add-ons/concepts/editor-auth-lifecycle
注意:加载项在 AuthMode.LIMITED 中执行时无法打开侧边栏或对话框。 您可以使用菜单项打开侧边栏和对话框,因为它们在 AuthMode.FULL 中运行。
来自onOpen 和 onEdit 中的错误“您无权调用 showSidebar” (来自 Google Apps 脚本问题跟踪器的问题)
状态:无法修复(预期行为)很抱歉在这里延迟回复。 在与工程团队进行多次对话后,我们决定不支持在 onOpen 和 onEdit 中打开 UI 元素(侧边栏、对话框)。 授权生命周期文档已更新,以明确您只能在这些模式下添加菜单项:
https://developers.google.com/gsuite/add-ons/concepts/addon-authorization#authorization_modes
我们理解这会影响您可以提供的可能的用户体验,我们为更改的突然性表示歉意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.