@@ -132,12 +132,17 @@ class AsyncAtlanClient(AtlanClient):
132132 _async_user_cache : Optional [AsyncUserCache ] = PrivateAttr (default = None )
133133
134134 def __init__ (self , ** kwargs ):
135+ # Initialize sync client (handles all validation, env vars, etc.)
135136 super ().__init__ (** kwargs )
136137
137- if self .oauth_client_id and self .oauth_client_secret :
138+ if self .oauth_client_id and self .oauth_client_secret and self .api_key is None :
139+ LOGGER .debug (
140+ "API Key not provided. Using Async OAuth flow for authentication"
141+ )
138142 from pyatlan .client .aio .oauth import AsyncOAuthTokenManager
139143
140144 if self ._oauth_token_manager :
145+ LOGGER .debug ("Sync oauth flow open. Closing it for Async oauth flow" )
141146 self ._oauth_token_manager .close ()
142147 self ._oauth_token_manager = None
143148
@@ -147,6 +152,7 @@ def __init__(self, **kwargs):
147152 client_secret = self .oauth_client_secret ,
148153 )
149154
155+ # Build proxy/SSL configuration (reuse from sync client)
150156 transport_kwargs = self ._build_transport_proxy_config (kwargs )
151157
152158 # Create async session with custom transport that supports retry and proxy
@@ -707,10 +713,6 @@ async def _handle_error_response(
707713 and response .status_code
708714 == ErrorCode .AUTHENTICATION_PASSTHROUGH .http_error_code
709715 ):
710- """
711- Async version of token refresh and retry logic.
712- Handles token refresh and retries the API request upon a 401 Unauthorized response.
713- """
714716 try :
715717 LOGGER .debug ("Starting async 401 automatic token refresh." )
716718 return await self ._handle_401_token_refresh (
@@ -761,6 +763,10 @@ async def _handle_401_token_refresh(
761763 download_file_path = None ,
762764 text_response = False ,
763765 ):
766+ """
767+ Async version of token refresh and retry logic.
768+ Handles token refresh and retries the API request upon a 401 Unauthorized response.
769+ """
764770 if self ._async_oauth_token_manager :
765771 await self ._async_oauth_token_manager .invalidate_token ()
766772 token = await self ._async_oauth_token_manager .get_token ()
0 commit comments