-1

I am trying to write a script that automatically deletes old Gmail email. I have it generally working, but after a few days, I get an email with this error message:

Your script, Batch Delete Gmail, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.

Start Function Error Message Trigger End

1/25/21 9:41 AM batchDeleteEmail Authorization is required to perform that action. time-based 1/25/21 9:41 AM

I'm trying to document the process here: https://superuser.com/questions/1618156/how-do-i-automatically-delete-old-google-email-gmail

Unfortunately, I don't really know what I'm doing. I have no experience with Google APIs or the Google Cloud Platform. The only reason I got as far as I have is because I got lucky reading a couple web pages and clicking on things until it started working.

I suspect that I have some kind of temporary "user" (or maybe a test user) that has access for a few days but is then automatically revoked. Unfortunately, I can't remember how I created that user.

Mateo Randwolf
  • 2,823
  • 1
  • 6
  • 17
lord_nimon
  • 173
  • 9

1 Answers1

0

Please, read the relevant Apps Script documentation to learn how to use Apps Script correctly, it has comprehensive guides for begginers like you. Never run code you don't know what is doing as it could be malicious. When copy pasting code always make sure you know what is doing.

Issue:

This is because you added some new code that needs authorization but you never executed the script manually or create the trigger after that point in order to give authorization for the recently added service.

Solutions:

Run the script manually and when the authorization window pops up, authorize the script.

or

Delete and create the time trigger again and again the authorization window will pop up and you can authorize the new service.

Mateo Randwolf
  • 2,823
  • 1
  • 6
  • 17
Marios
  • 26,333
  • 8
  • 32
  • 52
  • This doesn't work, because after I log in, Google tells me that it has blocked this app. That's why I'm going through the whole authorization process. – lord_nimon Jan 26 '21 at 15:36
  • @lord_nimon then create another app. – Marios Jan 26 '21 at 16:02
  • My point is that Google has determine that the code in this app cannot be trusted, and so it blocks it. If I create another app with the same code, that app will be blocked also. – lord_nimon Jan 26 '21 at 17:31