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
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.