I were able to delete emails from a test account in the test environment using the Gmail API.
It is necessary to prepare an environment in which the Gmail API works in advance, but I am not familiar with it, so I cannot help you build the environment.
from googleapiclient.discovery import...