簡體   English   中英

帶有 LIMITED auth 的附加組件無法打開側邊欄

[英]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

請加星標並發表評論,以便它盡快被收錄!

我重新測試,我看到:

  • 在安裝附加組件時,模式設置為 FULL
  • 然后打開文檔模式設置為無
  • 然后打開附加組件,關閉文檔然后重新打開,模式是有限的。

這與預期的生命周期一致,除了:

  • createTemplate 在 LIMITED 模式下失敗
  • 在 LIMITED 模式下,事件有 {user=} 沒有值:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM