Email Bot
Setting up oAuth tokens for long lived access to Gmail.
Setup a consent screen
Setup the consent screen on oAuth.
Setup Client
In GCP setup a OAuth 2.0 client. Save the credentials as credentials.json in the script folder.
Enable APIs
Applying terraform should be sufficient
$ cd terraform
$ tf apply --auto-approve
This does nothing more than enabling the APIs.
Run the Script
The script will run the and creates a token.json file, this file contains a refresh token that won't expire, provided your app is internal or published.