Yve*_*ves 5 google-docs google-apps-script google-oauth google-apps-script-addon
我有一个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
Run Code Online (Sandbox Code Playgroud)
很明显,根据插件授权生命周期,加载项处于有限模式并且showSidebar()应该成功(只需查看表中的列LIMITED).
- >我怀疑最近引入了一个bug或一个新的安全限制.
这里的记录是一个代码片段:
/**
* 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
}
}
Run Code Online (Sandbox Code Playgroud)
我重新测试了一下,发现:
这与预期的生命周期一致,除了:
08:22:36.457 onOpen(): {authMode=LIMITED, 源=文档, 用户=}
我认为用户权限有些丢失。
| 归档时间: |
|
| 查看次数: |
320 次 |
| 最近记录: |