Google Add-on adding menu items in limited mode app scripts

我与影子孤独终老i 提交于 2019-12-06 05:42:06

问题


We have a addon published in the new google app scripts add on store, but permissions don't seem to work correctly when using the add on in any spreadsheet other than the initial one it is installed in.

I'm seeing an issue where when a new spreadsheet is created and a user selects 'use this add on' from the 'manage add-ons' menu, our menu items don't get populated. For now we've been telling people to remove the add-on and reinstall to force the permissions flow for full permissions.

I looked at the permissions lifecycle guide at https://developers.google.com/apps-script/add-ons/lifecycle#opening and it appears that our onOpen function should be able to add the menu items in LIMITED permissions mode:

function onOpen(e) {
  var menu = SpreadsheetApp.getUi().createAddonMenu();
  menu.addItem("About OurApp", 'aboutOurApp');
  menu.addItem("Show Sidebar", "showSidebar");
  menu.addToUi();
  Logger.log(e);
  if (e && (e.authMode == ScriptApp.AuthMode.NONE || e.authMode == ScriptApp.AuthMode.LIMITED)) {
    return; // once user selects a menu item, full permissions should be asked for according to docs.
  } else {
   // we have full permissions - show the sidebar.
    var ui = HtmlService.createHtmlOutputFromFile('Sidebar')
     .setTitle('Our App');
    SpreadsheetApp.getUi().showSidebar(ui);
  }
}

Anyone know what we are doing wrong?

来源:https://stackoverflow.com/questions/25002352/google-add-on-adding-menu-items-in-limited-mode-app-scripts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!