1

I've a Google Sheets Published Addon with the following code to launch side bar on click of image in the sheet.

var ui = SpreadsheetApp.getUi();
function onOpen(e) {
  addMenu();
  if (e && (e.authMode == ScriptApp.AuthMode.LIMITED || e.authMode == ScriptApp.AuthMode.FULL)) {
   insertImage();
  }
}

function addMenu() {
 var menu = ui.createAddonMenu();
 menu.addItem('Launch', 'launchSidebar');
 menu.addToUi();
}

function insertImage() {
 try {
   const spreadSheet = SpreadsheetApp.getActive();
   const sheet = spreadSheet.getSheets()[0];
   const gridImage = sheet.insertImage("https://www.google.com/images/srpr/logo3w.png", 10, 1);
   gridImage.assignScript('launchSidebar');

 } catch (error) {
   Logger.log(error);
 }
}

function launchSidebar(){
  var template = HtmlService.createTemplateFromFile('sidebar');
  var html = template.evaluate().setTitle('Add on');
  ui.showSidebar(html);
}

When I click on image, I get the following error:

Google Apps Script: We're sorry, a server error occurred while reading from storage. Error code PERMISSION_DENIED.

It works fine when I am using google account associated with the script project but not working with other google accounts who uses the add-on as end user. Also, I am logged in using single account only in the browser.

Any suggestions would be appreciated.

Edit: I am not using multiple accounts; I've already checked those shared links and the solution on the post is to use single account which I am already doing. It didn't work on Incognito mode as well.

Please reopen the question.

Jayakrishnan
  • 4,232
  • 2
  • 23
  • 35
  • 1
    You say `It works fine when I am using google account associated with the script project` so what are you using when it doesn't work fine. – Cooper Mar 01 '23 at 20:18
  • Just one notion: you declared const sheets and after that called sheet.insertImage... I suppose you wanted to get single sheet, so your command spreadSheet.getSheets(); needs to match the following pattern: spreadSheet.getSheets()[0]; – Nikola Grujičić Mar 01 '23 at 21:21
  • @Cooper, it's not working with other google accounts who uses the add-on as end user. – Jayakrishnan Mar 02 '23 at 03:38
  • @NikolaGrujičić, apologies, it was a mistake. I've corrected the post. – Jayakrishnan Mar 02 '23 at 03:41
  • I am not familiar with the addon. I'd recommend contacting the addon creator – Cooper Mar 02 '23 at 04:05
  • @Cooper, I am the creator and I've added the code responsible for inserting image and calling script on click of image in the post. When the end users use my published add-on, they get this error – Jayakrishnan Mar 02 '23 at 04:09
  • What does sidebar look like? – Cooper Mar 02 '23 at 04:53
  • [Issue #69270374](https://issuetracker.google.com/issues/69270374). – TheMaster Mar 02 '23 at 06:09
  • @TheMaster, I am not using multiple accounts. – Jayakrishnan Mar 02 '23 at 06:31
  • End user is using multiple accounts and therefore they're getting errors. – TheMaster Mar 02 '23 at 19:15
  • @TheMaster, I am the end user, and I am testing it with single account only :) – Jayakrishnan Mar 03 '23 at 08:03
  • You maybe logged into multiple accounts.. or there maybe residual cookies in your browser... Have you tried in private/incognito window as suggested in the issuetracker? Add that information in your question. – TheMaster Mar 03 '23 at 08:33
  • @TheMaster, I tried with Incognito, and it still gives me the same error. When I make that account editor of my script, it works fine, this solution is not viable though. – Jayakrishnan Mar 06 '23 at 05:20
  • You may need to create a new issue in the issuetracker, explaining, why this issue is different from similar ones. – TheMaster Mar 06 '23 at 09:26
  • 1
    @TheMaster, can we call the methods of Sheets add-on from the image using the above flow? – Jayakrishnan Mar 07 '23 at 10:25
  • Interesting. So this is a published add-on? I only tested this with bound scripts and not published/test add ons. Maybe that's the cause of that error... – TheMaster Mar 07 '23 at 12:17
  • @TheMaster, yes, it's a published add-on. Is there any way to make it work? – Jayakrishnan Mar 07 '23 at 14:31
  • @Jayakrishnan Off the top of my head, I got nothing. Is this issue reproducible with a different addon/image? If so, you're better off explaining this issue to Google developers in the issuetracker. – TheMaster Mar 07 '23 at 16:52

0 Answers0