summaryrefslogtreecommitdiff
path: root/icktool
diff options
context:
space:
mode:
Diffstat (limited to 'icktool')
-rwxr-xr-xicktool19
1 files changed, 13 insertions, 6 deletions
diff --git a/icktool b/icktool
index 0866661..39def14 100755
--- a/icktool
+++ b/icktool
@@ -165,12 +165,13 @@ class Icktool(cliapp.Application):
return api
def _new_auth(self, api):
- url = api.get_auth_url()
- client_id, client_secret = self._get_client_creds(url)
+ c_url = api.get_controller_url()
+ auth_url = api.get_auth_url()
+ client_id, client_secret = self._get_client_creds(c_url, auth_url)
ac = ick2.AuthClient()
ac.set_http_api(api.get_http_api())
- ac.set_auth_url(url)
+ ac.set_auth_url(auth_url)
ac.set_client_creds(client_id, client_secret)
return ac
@@ -185,11 +186,17 @@ class Icktool(cliapp.Application):
sys.stderr.write('Error getting token: %s\n' % str(e))
sys.exit(1)
- def _get_client_creds(self, url):
+ def _get_client_creds(self, controller_url, auth_url):
cp = configparser.ConfigParser()
cp.read(self.settings['secrets'])
- client_id = cp.get(url, 'client_id')
- client_secret = cp.get(url, 'client_secret')
+
+ if cp.has_section(controller_url):
+ section = controller_url
+ else:
+ section = auth_url
+
+ client_id = cp.get(section, 'client_id')
+ client_secret = cp.get(section, 'client_secret')
return client_id, client_secret
def _prettyson(self, obj):