Skip to content

Commit 4ddd239

Browse files
authored
Resolve getActivePresentation Authorization issue
This resolves an issue I was seeing when walking through the quickstart guide here: https://developers.google.com/gsuite/add-ons/editors/slides/quickstart/progress-bar Essentially I am seeing the following in StackDriver Logs for a "Simple Trigger" when I refresh my Google Presentation browser window as directed to do in the guide: ``` Exception: Authorization is required to perform that action. at [unknown function](progress:6:30) ``` This change is to avoid running `getActivePresentation` in the global scope. Note that there are some references to fixing this by running any function in the Apps Script editor see https://developers.google.com/apps-script/guides/support/troubleshooting#execution_transcript, which appears to have resolve others experiencing this issue, but there are also some suggesting that this no longer works, see https://webapps.stackexchange.com/a/136707 and the comment from kurokirasama. I'm unsure as to what has changed to require this, but this at least resolves my immediate issue.
1 parent c863e75 commit 4ddd239

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

slides/progress/progress.gs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
*/
2020
var BAR_ID = 'PROGRESS_BAR_ID';
2121
var BAR_HEIGHT = 10; // px
22-
var presentation = SlidesApp.getActivePresentation();
2322

2423
/**
2524
* Runs when the add-on is installed.
@@ -49,6 +48,7 @@ function onOpen(e) {
4948
*/
5049
function createBars() {
5150
deleteBars(); // Delete any existing progress bars
51+
var presentation = SlidesApp.getActivePresentation();
5252
var slides = presentation.getSlides();
5353
for (var i = 0; i < slides.length; ++i) {
5454
var ratioComplete = (i / (slides.length - 1));
@@ -68,6 +68,7 @@ function createBars() {
6868
* Deletes all progress bar rectangles.
6969
*/
7070
function deleteBars() {
71+
var presentation = SlidesApp.getActivePresentation();
7172
var slides = presentation.getSlides();
7273
for (var i = 0; i < slides.length; ++i) {
7374
var elements = slides[i].getPageElements();

0 commit comments

Comments
 (0)