Apps Script: SpreadsheetApp.openById Permission Error, Even After Authorization

74 views
Skip to first unread message

Ray Yeo

unread,
Sep 8, 2025, 5:15:49 AMSep 8
to Google Apps Script Community

Hello everyone,

I'm encountering a very persistent and unusual permission issue with my Google Apps Script, and I'm hoping to get some help.

1. My Goal: I am trying to create an Apps Script that reads data from one Google Sheets file (my sales record) and then generates invoices in a different Google Sheets file (an invoice template).

2. The Problem: When the script reaches the SpreadsheetApp.openById() line, it consistently returns the following error: **Exception: Specified permissions are not sufficient to call SpreadsheetApp.openById. Required permissions: https://www.googleapis.com/auth/spreadsheets**

3. What I've Tried: I have tried the following troubleshooting steps, but none have resolved the issue:

  • The authorization pop-up window **does appear** when I first run the script.

  • I have clicked "Review permissions" and successfully granted all requested permissions, including the one for https://www.googleapis.com/auth/spreadsheets.

  • After I click "Continue", the script immediately fails with the same error. It does not proceed to execute any further code.

  • I have tried creating a brand new Apps Script project in a new, empty Google Sheets file, but the problem persists.

4. Relevant Code: The line of code causing the error is: **const salesSpreadsheet = SpreadsheetApp.openById(salesSpreadsheetId);**

5. Additional Information: The authorization pop-up appears and I confirm that I grant the permission. The error occurs right after authorization, without any code execution. I am using a personal Google Account.

Has anyone else experienced a similar issue, and if so, what was the solution? Thank you for your time and help!

Keith Andersen

unread,
Sep 8, 2025, 8:26:12 AMSep 8
to google-apps-sc...@googlegroups.com
How are you running this function? From a special menu? A trigger? The editor?



My website: https://sites.google.com/view/klaweb/
Passions: God, Family, Scriptures, Learning, Data Management, Google Sheets + App Script and much more!

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/542f1aa7-1a5b-45b9-9c11-1fdf4751784cn%40googlegroups.com.

Zack Reynolds

unread,
Sep 8, 2025, 8:34:59 AMSep 8
to google-apps-sc...@googlegroups.com
Do you have a "@OnlyCurrentDoc" somewhere in your code?

Ray Yeo

unread,
Sep 8, 2025, 9:20:08 AMSep 8
to google-apps-sc...@googlegroups.com
Hi, I'm glad with your replied, I am running the function directly from the Apps Script editor by clicking the "Run" button.

You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/fIzkmlRvLyc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/CAFKgK%2BE%2B0tiPAModiUUY04UbrJ1HXYb4YMFpYMOzH2uiiTKumA%40mail.gmail.com.

Keith Andersen

unread,
Sep 8, 2025, 9:22:01 AMSep 8
to google-apps-sc...@googlegroups.com
Create a special menu and try and run it from that. 



My website: https://sites.google.com/view/klaweb/
Passions: God, Family, Scriptures, Learning, Data Management, Google Sheets + App Script and much more!

Edward Wu

unread,
Sep 8, 2025, 12:33:06 PMSep 8
to google-apps-sc...@googlegroups.com
You could also double-check to make sure that the user running the script has edit permissions to both Google Sheets *and* the relevant tabs (i.e. make sure there's no protection on the tab that affects the user running the script).

--
Reply all
Reply to author
Forward
0 new messages