diff --git a/.gitignore b/.gitignore index 6a18ad4..66d6e2a 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,5 @@ ENV/ # Rope project settings .ropeproject +.flake8 +config.ini diff --git a/authenticator.py b/authenticator.py index b5eee1a..802bba6 100644 --- a/authenticator.py +++ b/authenticator.py @@ -7,6 +7,7 @@ import requests import os import json import urlparse +import configparser def api_auth(user, passwd, host): @@ -22,11 +23,16 @@ def api_auth(user, passwd, host): def main(): """Main logic entrypoint""" - API_HOST = "https://beta.api.core-networks.de/" - API_USER = "your.email@example.com" - PASSWORD = "secret" - auth_token = r.json() + config_path = os.path.join(os.path.expanduser("~"), "config.ini") + config = configparser.ConfigParser() + config.read(config_path) + + API_HOST = config['API']['HOST'] + API_USER = config['API']['USER'] + PASSWORD = config['API']['PASSWORD'] + + auth_token = api_auth(API_USER, PASSWORD, API_HOST) print auth_token diff --git a/example_config.ini b/example_config.ini new file mode 100644 index 0000000..05e323b --- /dev/null +++ b/example_config.ini @@ -0,0 +1,4 @@ +[API] +HOST = https://beta.api.core-networks.de/ +USER = your.email@example.com +PASSWORD = secret