5

Recently I switched my google slides script runtime from Rhino to V8. I tested my Add-on but I got an error:

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

My script uses PropertiesService.getUserProperties(). I found out that I had to logout from my google account and login again and it worked.

I can imagine that this could be pain also for other users who are using this add-on. Is there any other way how to fix this error?

appscript.json config

{
  "timeZone": "Europe/Bratislava",
  "runtimeVersion": "V8",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER"
}

Also I am developing add-on localy on my PC nad using clasp to push the code to the App script.

Update

I created minimal project to reproduce this error and I found out that PropertiesService.getUserProperties() was not the issue. Turns out that after switching from Rhino to V8, I am not able to call any appscript functions.

// Code.gs
function onInstall(event) {
    onOpen(event);
}

function onOpen(event) {
    SlidesApp.getUi().createAddonMenu()
        .addItem('Open the sidebar', '_showSidebar')
        .addToUi();
    _showSidebar();
}

function _showSidebar() {
    var ui = HtmlService
        .createHtmlOutputFromFile('index')
        .setTitle('Test add-on');
    SlidesApp.getUi().showSidebar(ui);
}

function getCurrentSlideObjectId() {
    var page = SlidesApp.getActivePresentation().getSelection().getCurrentPage();
    if (page && page.getPageType() === SlidesApp.PageType.SLIDE) {
        return page.getObjectId();
    }
    return null;
}

With template:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    
    <script>
       const onButtonClick = () => {
         google.script.run
          .withSuccessHandler(success)
          .withFailureHandler(error)
          .getCurrentSlideObjectId()
       }
       const success = (currentSlideObjectId) => {
         console.log("It works!", currentSlideObjectId);
       }
       const error = (error) => {
         error = typeof error === 'string' ? new Error(error) : error;
         console.error(typeof error === 'object' && error !== null ? error.message : error);
       }
    </script>
  </head>
  <body>
    <button onclick="onButtonClick()">Click me</button>
  </body>
</html>

Currently I am logged into my google drive with 2 different accs. When testing the add-on on different acc than Google chrome is logged in, an error will come out.

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

tprieboj
  • 1,680
  • 6
  • 31
  • 54
  • 1
    Why do you want to use [tag:V8]? I mean, is there an specific benefit that you are looking for ? – Rubén Jun 27 '20 at 20:31
  • Related: https://stackoverflow.com/q/60453863/1595451, https://stackoverflow.com/q/60356124/1595451 – Rubén Jun 27 '20 at 20:35
  • 3
    @Rubén Better performance, ES6, better logging and possibly fixing of some bugs like [this](https://stackoverflow.com/questions/61576767/g-suite-add-on-refusing-to-connect-to-drive-how-to-solve-drive-google-com-refu) also we had a problems with minified code (can't remember the details) – tprieboj Jun 27 '20 at 21:06
  • Have you seen the links on my last comment? – Rubén Jun 27 '20 at 21:11
  • [This post](https://stackoverflow.com/questions/60453863/slides-app-getactivepresentation-error-after-v8-migration) I also use 2 different accounts 1 in chrome browser and the other in google drive. But this was not problem with Rhino. – tprieboj Jun 27 '20 at 21:43
  • 2
    Just curious but by any chance were you logged into another account with the same browser when this happened? – Cooper Jun 27 '20 at 22:29
  • Yes, my browser uses different acc than my google drive login (well... I am using 2 google accs for my drive). And this does not occure in incognito mode. – tprieboj Jun 27 '20 at 23:55

1 Answers1

2

It's a known issue by Google IssueTracker that an add-on can lead to PERMISSION_DENIED under certain conditions, you could go ahead and click +1 to increase the issue popularity. As Rubén said, this issue could also follow multiple logged users so go ahead and use the +1 if your scenario is similar to that thread.

Jacques-Guzel Heron
  • 2,480
  • 1
  • 7
  • 16