I have a Python script that goes into my Gmail inbox and looks for certain emails based off the subject line. I would like to automate this process; however, my credentials seem to expire on a weekly basis. Whenever they expire and I run my script, it opens up my browser and prompts me to authorize my app. Is there anyway this can be bypassed so that I can automate my script and not have to constantly authenticate my app through the browser?
Thanks!
If your app is in the testing phase the refresh token will expire after a week. If you want your refresh token to last longer you will need to set your application to production and go though the verification process.
if this is a google workspace email account then you should consider using a service account for authorization and setting up domain wide delegation.