Switching from Rhino to V8 causes Error code PERMISSION_DENIED

380 Views Asked by At

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.

1

There are 1 best solutions below

0
Jacques-Guzel Heron On

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.