Search code examples
google-apps-scriptgoogle-sheetsgoogle-cloud-platformweb-applicationsgoogle-oauth

Why my Google Apps Script permissions are revoked after few days?


I made a simple Telegram bot that runs on Google Spreadsheet with a help of Google Apps Script. It does a lookup in sheets and optionally saves an uploaded file to my Google Drive.

Previously it was a Script attached to the Spreadsheet. Later Google suggested to create an App in Google Cloud Console and assign the script to that App id, so all API calls are accountable.

Script app is not verified and runs in "Publishing status: Test" mode. I only need it to access my account's data.

The permissions I gave to the script (access to Sheets, Drive) get automatically revoked without any notice after about 2-3 days, and the bot stops working. Until I revisit the Shpreadsheet, open Extensions - Apps Script, run any function and it asks for authorization again. Then the bot works for a couple of days more.

How can I make the permissions I give permanent?


Permissions I granted (again) to my app: App settings in my Account

Updated menu of the Spreadsheet app: Google Spreadsheet menu bar


Solution

  • From Setting up your OAuth consent screen > Testing

    Authorizations by a test user will expire seven days from the time of consent. If your OAuth client requests an offline access type and receives a refresh token, that token will also expire.

    Considering the above you have to get your app to be verified by Google.