Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

I am building a system that use some tokens and keys to access services, but where is the best place to store then? I want to push to github without pushing the tokens.

Currenctly i placed then into a blank file named Constants.py and in the main python file i make an import Constants

Constants.py:

API_KEY_SERVICE = "ABC123ABC"

Main.py:

import Constants

 service_key = Constants.API_KEY_SENDGRID

1 Answer

0 votes
by (25.1k points)

What is you are doing is the recommended way of doing this. One other thing that you should take care of is that if you are using git then your constants.py should not be included in your repository, for this, just include your constants.py file name in .gitignore file.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...