diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-06-18 20:22:09 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-06-18 20:22:09 +0300 |
commit | 5cff84723324b1fc01ea0962c0412bf7dc6027b4 (patch) | |
tree | 017d059127233d26f3984198ff6d0cb0471b7a4d /icktool | |
parent | e9839fa9e91155f20ffdb48bc6b8d3d672cb8061 (diff) | |
download | ick2-5cff84723324b1fc01ea0962c0412bf7dc6027b4.tar.gz |
Change: look up credentials using controller URL (fallback auth url)
Diffstat (limited to 'icktool')
-rwxr-xr-x | icktool | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -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): |