Learn the most secure way to manage secrets in Python projects - no more .env files in your project directory.
Great for anyone who uses Jupyter or works in python frequently.
Key Points:
00:00 - Introduction to secure secrets management in Python
00:50 - Setting up a dedicated secrets directory
01:26 - Using dot-env values for centralized access
02:32 - Managing multiple API keys across projects
Keep your secrets safe! I'll show you how to:
Set up a dedicated ~/.secrets directory
Use python-dotenv for secure configuration
Access multiple API keys across different projects
Prevent accidental Git commits of sensitive data
```
pip install python-dotenv
```
```
import os
from dotenv import load_dotenv
secrets_dir = os.path.expanduser("~/Documents/secrets")
config = {
**dotenv_values(secrets_dir + "/.env.openai"),
}
config.get("OPENAI_API_KEY")
```