Search code examples
google-apps-scriptgoogle-slides-api

refreshSlides Exception: Action not allowed


I Have a working Google slides version 2020, I copied this to version 2021. But now I get the error

Exception: Action not allowed
refreshSlides   @ Code.gs:9

The script is :

function refreshSlides(){
  var currentPresentation, i, linkedSlide, numSlides
  
  // loop through all slides and refresh them
    currentPresentation = SlidesApp.getActivePresentation();
    numSlides = currentPresentation.getSlides().length;
    for (i = 0; i < numSlides; i++) {
      linkedSlide = currentPresentation.getSlides()[i]
      linkedSlide.refreshSlide();
    Utilities.sleep(5000);

    }
}

I tried to add authorization by adding (see below) to appsscript.json

  "oauthScopes": [
    "https://www.googleapis.com/auth/presentations.currentonly",
    "https://www.googleapis.com/auth/presentations"
  ],

But that didn't help. What am I missing here??


Solution

  • As it is stated in the official documentation, refreshSlide() drops an error:

    If read-access to the source presentation is no longer available.

    Make sure you have read-access to the active presentation and to every slide.