Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add-on with LIMITED auth cannot open sidebar

I have a Google docs add-on which is programmed to open the sidebar as soon as the document is open. Of course this requires the add-on to be installed and enabled in the document.

I see that, since a week, the sidebar auto open feature, which is very useful in our use case, no longer works.

In StackDriver logs I see this report :

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 

So clearly, the add-on is in LIMITED mode and showSidebar() should succeed, according to the addon authorization lifecyle (just look at the column LIMITED in the table).

--> I suspect a bug or a new security limitation was introduced recently.

For the record here is a code snippet :

/**
 * 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
    }
}
like image 620
Yves Avatar asked Nov 08 '22 13:11

Yves


1 Answers

Yesterday we've noticed exactly the same problem as you Yves. However for us it occurs in a Google Sheets addon.

I've created an issue at Google: https://issuetracker.google.com/issues/69824548

Please star and comment so it gets picked up soon!

like image 60
Hannes Holst Avatar answered Nov 14 '22 21:11

Hannes Holst