diff --git a/lenticular_cloud/hydra.py b/lenticular_cloud/hydra.py index be6a31a..fafaeff 100644 --- a/lenticular_cloud/hydra.py +++ b/lenticular_cloud/hydra.py @@ -24,6 +24,7 @@ class HydraService: client_name = app.config['OAUTH_ID'] client_secret = app.config['OAUTH_SECRET'] + public_url = app.config['PUBLIC_URL'] clients = list_o_auth_2_clients.sync_detailed(_client=self.hydra_client).parsed if clients is None: @@ -35,8 +36,7 @@ class HydraService: break if client is None: - public_url = app.config['PUBLIC_URL'] - client = OAuth20Client( + client_req = OAuth20Client( client_name="identiy_provider", # client_id=client_id, client_secret=client_secret, @@ -46,11 +46,13 @@ class HydraService: redirect_uris=[ f"{public_url}/oauth/authorized" ], token_endpoint_auth_method="client_secret_basic", ) - ret = create_o_auth_2_client.sync(json_body=client, _client=self.hydra_client) + ret = create_o_auth_2_client.sync(json_body=client_req, _client=self.hydra_client) if ret is None: raise RuntimeError("could not create account") + client = ret else: client.client_secret = client_secret + client.redirect_uris = [ f"{public_url}/oauth/authorized" ] ret = set_o_auth_2_client.sync(id=client.client_id, json_body=client, _client=self.hydra_client) if ret is None: raise RuntimeError("could not update account")