Here’s how to safely store and use credentials for the Python gspread library, a Python API for Google Sheets.
Background: How To Keep A Secret, by Glyph The most relevant parts start around 15:00, but watch the whole thing, it’s great and worth your time.
Pre-requisites
Install keyring: pip install keyring
or equivalent.
Storing credentials
Create service account credentials as explained in the gspread docs. This ends with you having a JSON credentials file on your disk somewhere (unacceptable).