Skip to content

Commit 7d204c9

Browse files
committed
fix(client): Remove duplicated auth resolution logic
- AdminClient: Pass auth=True or auth_token directly (was duplicating the if/elif/else chain) - RegistryClient: Use get_token() callable for current token value
1 parent 1bfe3b8 commit 7d204c9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/amp/client.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,17 +357,16 @@ def get_token():
357357
if admin_url:
358358
from amp.admin.client import AdminClient
359359

360-
# Pass auth=True if we have a get_token callable from auth file
361-
# Otherwise pass the static token if available
360+
# Pass through the same auth configuration to maintain consistent behavior
362361
if auth:
363-
# Use auth file (auto-refreshing)
362+
# Use auth file (auto-refreshing via AuthService)
364363
self._admin_client = AdminClient(admin_url, auth=True)
365364
elif auth_token or os.getenv('AMP_AUTH_TOKEN'):
366-
# Use static token
367-
static_token = auth_token or os.getenv('AMP_AUTH_TOKEN')
368-
self._admin_client = AdminClient(admin_url, auth_token=static_token)
365+
# Use static token (explicit param takes priority over env var)
366+
token = auth_token or os.getenv('AMP_AUTH_TOKEN')
367+
self._admin_client = AdminClient(admin_url, auth_token=token)
369368
else:
370-
# No auth
369+
# No authentication
371370
self._admin_client = AdminClient(admin_url)
372371
else:
373372
self._admin_client = None
@@ -376,8 +375,13 @@ def get_token():
376375
if registry_url:
377376
from amp.registry import RegistryClient
378377

379-
# Pass resolved token to RegistryClient (for authenticated operations)
380-
self._registry_client = RegistryClient(registry_url, auth_token=flight_auth_token)
378+
# Use the same auth approach - get current token value
379+
# Registry client doesn't call APIs per-request, so static token is fine
380+
if get_token:
381+
current_token = get_token()
382+
self._registry_client = RegistryClient(registry_url, auth_token=current_token)
383+
else:
384+
self._registry_client = RegistryClient(registry_url)
381385
else:
382386
self._registry_client = None
383387

0 commit comments

Comments
 (0)