Last active
May 15, 2021 02:58
-
-
Save lordloh/4a7047049a522570642fd9d941890222 to your computer and use it in GitHub Desktop.
A snippet to avoid hard coding user names and passwords in python scripts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you hardcode usernames and passwords, you cannot check in the code to public git repositories. | |
# A solution I am using is to create a `credentials.json` file and storing the password there | |
# cerdentials.json : | |
# { | |
# "user":"bharath", | |
# "password":"bharath_secret_password" | |
# } | |
# | |
# add this file to .gitignore | |
# | |
# This file my be protected on apache web server using - | |
# <Files ~ "\credentials.json$"> | |
# Require all denied | |
# </Files> | |
import json | |
with open('credentials.json') as json_data: | |
credentials = json.load(json_data) | |
login(username=credentials['user'] password=credentials['password']") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks nigga!