[Python] How do I Secure a `credential.json` file in a Production Server

Discussão em 'Python' iniciado por Stack, Fevereiro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I am connecting to a google service via a (downloaded)credential.json file, following is my snippet:

    from google.oauth2 import service_account

    GS_CREDENTIALS = service_account.Credentials.from_service_account_file(
    os.path.join(BASE_DIR, 'credential.json'))


    this is working perfectly, however I want to to use the file in my production server, but I know it is not a good practice to upload API file/key to a production server, I am using python-decouple package to store my other keys, and using it as environment variables in the production server.

    My question is how do I use a 'file' and its key contents securely in a production server?

    I tried using python-decouple package, it works perfectly on individual keys, but on files I cannot managed to make it work.

    Continue reading...

Compartilhe esta Página