using .env files in Python to obfuscate API keys

How to make this work:

You need to export the sendgrid key.

Create a file called .env in the same project's directory.

The file should have one line:

export SENDGRID_API_KEY = "contents of key"

Then To run the script and get the contents of the key set up your crontab like this.  In this example our script is called mfscp.py.

0 0 1 * * /usr/bin/python3.10 //home/clamm/PycharmProjects/mfscp/.env && home/clamm/PycharmProjects/mfscp/mfscp.py

Comments

Popular posts from this blog

MAKING SOME POOP==Python classes constructor and instantiating; class variables

Python POOP: "name mangling"--how to make class data private or public (odd in Python!)

Installing Python virtual environments on Windows using pyenv and vscode's terminal Salesforce tix 8868