How to Hide API Keys in Python: An Environment Variables Example

Опубликовано: 29 Июнь 2023
на канале: PuppyCoding – for Python & AI
3,012
91

If you use OpenAI's ChatGPT API, or most other APIs, here's how to keep your keys secret and safe in Python. This tutorial shows you how to use "environment variables" and the "dotenv" module.

The concept is to move the API keys from your Python code to your Python environment. Your programs can still access the keys, but they won't be visible to others if you share your code.

Get the source code here:
https://puppycoding.com/2023/07/02/hi...

For code that you deploy to a server, using ".env" files is not a good idea. I explain two alternative methods in this video:
   • How to Hide API Keys When Deploying C...  

00:00 Introduction
01:19 Step 1: Create a hidden file to store API keys
02:59 Step 2: Get the API key from the hidden file
04:40 Testing the code
05:12 Adding other API keys

#Python #programming


На этой странице сайта вы можете посмотреть видео онлайн How to Hide API Keys in Python: An Environment Variables Example длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь PuppyCoding – for Python & AI 29 Июнь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 3,012 раз и оно понравилось 91 зрителям. Приятного просмотра!