enable the api in google cloud console: https://console.cloud.google.com/workspace-api
crate the oauth consnet: https://developers.google.com/gmail/api/quickstart/python
install api library:
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
download credentials.json from here: https://console.cloud.google.com/apis/credentials