Hello. Actually I use oauth2client.service_account import ServiceAccountCredentials for GSpread with the following code:
# Set up the credentials
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name('PATH_TO_JSON.json', scope)
client = gspread.authorize(creds)
# Open the Google Sheet using its name
sheet = client.open("NAME_OF_SHEET").worksheet('NAME_OF_WORKSHEET')
But the json file is not very practical for localhost and cloud app.
So for local I need to emplement it in the local secrets.toml file and for the app to integrate it in the secrets app setting.
How can I do this?
Thanks!
In continuation of @Charly_Wargnier’s suggestion on using the Secrets management, you can open up the json file, then copy and paste it into the text box of the Secrets management on Community Cloud, finally format the credentials from JSON format to be in TOML format.
I’ve created a dictionary google_service_account = {"type" = "service_account", "project_id", AND_SO_ON}
and added this to the secrets.toml and secrets area