2

Looking for help/directions on the following issue:

  • Apps script Web App losing permissions frequently.

A detailed explanation of the deployment:

I have a GAS Web App that has been published as a Web App and it is being "Executed as Me".

I have also created a version, and the script is then published on this specific version. Script also has a few time-driven triggers which are also set up on a specific published version.

According to Google Apps Script Documentation, above are the best practices to be used for the deployment of an Apps Script project as Web App.

But recently, this GAS/Web app is losing permissions automatically even though there is no change in the script. So eventually, script triggers start throwing an error: "Authorization is required to perform that action".

Is there anything I am missing?

FYI, below are the permissions required for my script:

 "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets.readonly", 
"https://www.googleapis.com/auth/userinfo.email", 
"https://www.googleapis.com/auth/spreadsheets.currentonly", 
"https://www.googleapis.com/auth/spreadsheets", 
"https://www.googleapis.com/auth/gmail.readonly", 
"https://www.googleapis.com/auth/gmail.modify", 
"https://mail.google.com/", 
"https://www.googleapis.com/auth/script.scriptapp", 
"https://www.googleapis.com/auth/script.container.ui", 
"https://www.googleapis.com/auth/forms", 
"https://www.googleapis.com/auth/drive.readonly", 
"https://www.googleapis.com/auth/drive"],
  • 1
    If you indeed believe that the script automatically loses auth without any problem in your script, create a issue in the Google issue tracker – TheMaster Dec 09 '19 at 11:26
  • Is it possible that you are signed in with multiple accounts? – ziganotschka Dec 09 '19 at 12:09
  • @ziganotschka No, I don't have any other login. Is there anything with firewall? – Dadasaheb Sawant Dec 10 '19 at 01:15
  • @TheMaster Yes, I am thinking about that but before that I just wanted to do research little bit. – Dadasaheb Sawant Dec 10 '19 at 01:16
  • Does this behavior occur only with one very specific Web App? Could you provide the code that would reproduce the problem? – ziganotschka Dec 17 '19 at 16:23
  • @ziganotschka No, this behaviour is not specific to only one Web App. SInce this issue occurs sometimes once or twice a month, I am not sure if there is any specific code causing this issue. – Dadasaheb Sawant Dec 18 '19 at 01:57
  • Which kind of triggers cause the problem and what are those triggers supposed to do? E.g., for URL fetch requests you might need an additional scope "https://www.googleapis.com/auth/script.external_request" – ziganotschka Dec 18 '19 at 10:24
  • @ziganotschka Triggers are mainly using Spreadsheet, Google form, Google drive and Gmail only. This issue is not always reproducible. It is very intermittent. That's the reason, I can not say if anything is wrong in the script but more related to permissions from google account. – Dadasaheb Sawant Dec 19 '19 at 07:06
  • I am wondering if this occurs when the script times out? https://stackoverflow.com/a/43984564/11599789 Also, maybe this troubleshooting information is helpful: https://developers.google.com/apps-script/guides/support/troubleshooting#common_errors – ziganotschka Dec 19 '19 at 09:52
  • What are your settings for "Who can access the Web App". If e.g. only your domain users can access the Web App, but some of your users are logged in with multiple accounts (or with their private, non-domain account) this would be the reason for the lack of authorization. – ziganotschka Dec 20 '19 at 08:47
  • 1
    I have the same issue. My SpreadSheets script serves my simple Telegram bot: does a lookup in a table and optionally stores photo uploads in my Google drive. From time to time it looses my permissions with no reason. Have you find a solution yet? – Serge Mar 13 '21 at 05:59
  • That seems to be an intermittent issue with Google's identity platform. I am fairly experienced in Apps Script, but currently one of my clients started getting the same problem. I haven't been able to determine the issue precisely, but it seems to be dependent on the number of token grants to the same user (the app uses a separate implementation of Google's OAuth flow for server-side web apps). – Oleg Valter is with Ukraine Apr 15 '21 at 03:55
  • FYI, if the consent screen is set to testing mode, the authorization [will be revoked after a week](https://stackoverflow.com/a/66859421/11407695): (thanks Rubén) I never reread the docs after the change and assumed everything apart from the review process works the same as before and seems like I was bitten by this for my negligence. Please do take a look - if this is your case, we can close this one as a duplicate. – Oleg Valter is with Ukraine Apr 15 '21 at 07:28

0 Answers0