Intermittent permissions accessing a spreadsheet

73 views
Skip to first unread message

Adi Ofer

unread,
Jan 26, 2026, 10:46:15 AM (9 days ago) Jan 26
to Google Apps Script Community
Hi,

I have an Apps Script which front-ends a Spreadsheet. The spreadsheet permissions are set to "Anyone with the link" is a "Viewer", and the Apps Script is deployed with the following settings:
  • Execute as: user accessing the web app
  • Who has access: Anyone with Google account.
For several weeks all the users have used the app without any issue (and yes, every user action accesses the spreadsheet). Starting this week, though (from Jan 20, 2026) some users have encountered intermittent permission issues:
This appears to be an intermittent issue. E.g. a user who encountered the error was able to successfully use the app (that is, access the spreadsheet) both before and after (literally 30 seconds after) encountering the error. No changes were made to the settings of either the spreadsheet or the Apps Script deployment for many weeks now.

It looks like a problem on the Google side, perhaps one which was introduced recently. Am I missing something?

Has anyone else seen a similar issue? Any thoughts or advice?

Thank you!

Kildere S Irineu

unread,
Jan 26, 2026, 1:07:16 PM (9 days ago) Jan 26
to google-apps-sc...@googlegroups.com

"You do not have permission to call DocumentApp.openById. Required permissions: https://www.googleapis.com/auth/spreadsheets"

Esse erro não faz sentido direto porque DocumentApp.openById está relacionado ao serviço Google Docs, enquanto a permissão mencionada (https://www.googleapis.com/auth/spreadsheets) se refere ao Google Sheets. Isso indica uma inconsistência interna da execução de escopos na plataforma do Apps Script.


✅ Possíveis causas:

  1. Alterações recentes nos escopos automáticos do Apps Script:

    • Pode haver uma mudança silenciosa no modo como o Apps Script trata escopos dinâmicos quando o script é executado como “usuário acessando o app”.

    • Se o script acessar vários serviços (Sheets, Docs, Drive), o Apps Script pode confundir ou falhar ao pedir consentimento corretamente, especialmente com permissões mínimas.

  2. Usuários com tokens inconsistentes (token scopes):

    • Se um usuário deu consentimento antes da mudança de escopos exigidos, seu token OAuth pode estar desatualizado/inválido momentaneamente.

    • Isso explicaria o fato de funcionar 30 segundos depois: o token pode ter sido renovado automaticamente.

  3. Comportamento intermitente de serviços do Google Apps Script:

    • Há relatos esporádicos em fóruns como o Stack Overflow e o Issue Tracker do Google sobre erros parecidos (ex. Exception: You do not have permission...) ocorrendo após atualizações nos serviços.


🛠️ Recomendações para mitigar o problema:

1. Evitar escopos implícitos – Declare-os explicitamente (se usar Manifest V2 ou V3)

Se estiver usando o appsscript.json, declare todos os escopos usados:

Isso força o Apps Script a pedir autorização completa já no primeiro uso, evitando falhas intermitentes.


2. Considere mudar para “Executar como: proprietário do script”

Se você controla os dados e pode assumir essa responsabilidade, mudar para “Executar como proprietário do script” pode eliminar a variação entre usuários.


3. Registre os erros com try/catch e console.error()

Isso permite mapear quando, com quem e em quais condições o erro ocorre:

try { const doc = DocumentApp.openById('DOCUMENT_ID'); // uso do documento } catch (e) { console.error('Erro ao abrir o Documento:', e.message); throw e; }

4. Crie uma função de teste manual para forçar novo consentimento

Peça para os usuários afetados executarem manualmente uma função simples que usa todos os serviços envolvidos — isso forçará a atualização dos tokens.

function forcarPermissoes() { SpreadsheetApp.openById('ID_PLANILHA'); DocumentApp.openById('ID_DOCUMENTO'); DriveApp.getFileById('ID_ARQUIVO'); }

📢 Sobre relatos semelhantes

Sim, outros desenvolvedores também estão enfrentando comportamentos parecidos, e não há nota oficial do Google no momento, mas pode estar relacionado a:

  • Nova política de escopos mínimos (OAuth granular scopes)

  • Transição interna de segurança no runtime do Apps Script

  • Alterações nos endpoints de API silenciosas


📌 Conclusão

Você não está sozinho — há indícios claros de alteração recente no backend da plataforma. Para mitigar, recomendo:

  • Declarar escopos no appsscript.json

  • Considerar rodar como "proprietário"

  • Usar logs para rastrear

  • Forçar renovação de permissões com uma função dedicada


--
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/cc6ded9d-df2a-4bc1-a434-05436771e693n%40googlegroups.com.

Adi Ofer

unread,
Jan 26, 2026, 1:42:55 PM (9 days ago) Jan 26
to Google Apps Script Community
Thank you for your detailed response, much appreciated.

There may have been a change in the manner in which Google asks the user to approve the permission scopes requested by the app: pressing "continue" on that screen used to approve all the scopes, whereas users now tell me that they need to individually approve each requested scope before hitting "continue". So it appears that the error happened to a user who clicked "continue" without checking off the scopes.

This, of course, does not explain the intermittent issues another user experienced.

Thanks again!

Web Dev

unread,
Jan 29, 2026, 2:27:52 PM (6 days ago) Jan 29
to Google Apps Script Community
one possibility of such issue is that your users have multiple Google accounts and because you only shared the document with one account but they're logged in into another account they're hitting that issue.

Adi Ofer

unread,
Jan 29, 2026, 9:38:37 PM (6 days ago) Jan 29
to Google Apps Script Community
Thank you for your response.

In my case "Anyone with the link" is set as a "Viewer" --- it's not an account specific type of sharing. I think that there were two separate issues, as mentioned in my previous message: the recent change in the permissions UI requiring uses to checkbox the permissions, and a separate, intermittent glitch on the Google side.

Web Dev

unread,
Jan 30, 2026, 1:05:28 PM (5 days ago) Jan 30
to Google Apps Script Community
I guess I would need to debug your code to get a better understanding of how your logic in UI is working. Feel free to make a copy and share with me.

Adi Ofer

unread,
Jan 31, 2026, 1:12:25 AM (5 days ago) Jan 31
to Google Apps Script Community
Sorry if I haven't been too clear. The (non-intermittent) problem was diagnosed: it had nothing to do with the code. Rather, due to changes in the Google permissions UI the user in question ended up not granting the app the right permissions. Apologies if this wasn't clear from my previous message.

Regardless, thanks everyone for your willingness to help.
Reply all
Reply to author
Forward
0 new messages