Python Forum
Best practice for sharing gspread credentials to server - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Best practice for sharing gspread credentials to server (/thread-11904.html)



Best practice for sharing gspread credentials to server - shlomiLan - Jul-31-2018

I'm using gspread (to write data to Google spreadsheet) and my app runs on Heroku.
I credentials json file (for gspread), that I don't want to put on Git and I can't manually upload to Heroku.
What is the best way access this data in the server so that my code can run there as well? maybe write some of the information in environment variables and read it in my app?

This is the code that I have now:
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'    
credentials = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
Thanks.


RE: Best practice for sharing gspread credentials to server - micseydel - Jul-31-2018

Assuming that the environment variable definition is relatively secure, yes, that sounds like a decent way to go. I'm no Heroku expert, so there might be a better way, but I've seen env vars used in Jenkins successfully.