Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put Google Cloud client/service account secret json file?

So I have the following code in my project

flow = flow_from_clientsecrets(client_secrets_file, scope=flow_scope, redirect_uri='urn:ietf:wg:oauth:2.0:oob')

Which reads from a client_secret.json file in order for me to use Google Cloud API. Here's another piece of code that sets an environment variable for Google Cloud Storage.

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = os.path.join(dir, '../config/service_account.json')

Normally, I would put these info in environment variables, but I don't know how to do that with json files. Where should I put these files or how should I alter them so that I can safely push my code online without revealing my credentials?

Any help is appreciated.

like image 917
DUNG NGUYEN TIEN Avatar asked Oct 23 '25 15:10

DUNG NGUYEN TIEN


1 Answers

You can store the file in a secret and access that secret through the Google Cloud Secret Manager. This is also recommended over storing your sensitive data in an environment variable. You can find more information on how to set this up here: https://cloud.google.com/secret-manager/docs/

like image 196
JMS Avatar answered Oct 26 '25 05:10

JMS