How can I best structure a program?
I have some classes in different .py files doing REST API calls to a service using a Bearer auth key.
Since I don't want to store the key in every class I would want to know how I should best approach this.
Where and how should I store the key? How should the classes using this key access it? What is industry best practice?
One good approach would be to make a Base class which loads the api key (and potentionally any other env variables) from a .env file and stores it as a class member. Then all classes which need the api key access would just inherit from Base class.
Don't forget to add .env file to .gitignore, so you don't share all the private information with other users.
Program structure private key and requets