简体   繁体   中英

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM