- 建立cert, attachments 目錄
- 將cw-gmail-oauth-credential.json放到cert底下
https://developers.google.com/gmail/api/quickstart/python
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
- create a service account: https://console.developers.google.com/iam-admin/serviceaccounts/
- in options, create a key: this key is your usual client_secret.json - use it the same way
- add owner permission to this service account (Member name = service account ID = service account email ex: thomasapp@appname-201813.iam.gserviceaccount.com
- copy the email address of your service account = service account ID
- simply go in your browser to the Google sheet you want to interact with
- go to SHARE on the top right of your screen
- go to advanced settings and share it with email address of your service account ex: thomasapp@appname-201813.iam.gserviceaccount.com