33import requests as requests_http
44from .general import General
55from .sdkconfiguration import SDKConfiguration
6- from typing import Dict
6+ from typing import Callable , Dict , Union
77from unstructured_client import utils
88from unstructured_client .models import shared
99
@@ -14,7 +14,7 @@ class UnstructuredClient:
1414 sdk_configuration : SDKConfiguration
1515
1616 def __init__ (self ,
17- api_key_auth : str ,
17+ api_key_auth : Union [ str , Callable [[], str ]] ,
1818 server : str = None ,
1919 server_url : str = None ,
2020 url_params : Dict [str , str ] = None ,
@@ -24,7 +24,7 @@ def __init__(self,
2424 """Instantiates the SDK configuring it with the provided parameters.
2525
2626 :param api_key_auth: The api_key_auth required for authentication
27- :type api_key_auth: Union[str,Callable[[], str]]
27+ :type api_key_auth: Union[str, Callable[[], str]]
2828 :param server: The server by name to use for all operations
2929 :type server: str
3030 :param server_url: The server URL to use for all operations
@@ -39,7 +39,11 @@ def __init__(self,
3939 if client is None :
4040 client = requests_http .Session ()
4141
42- security = shared .Security (api_key_auth = api_key_auth )
42+ if callable (api_key_auth ):
43+ def security ():
44+ return shared .Security (api_key_auth = api_key_auth ())
45+ else :
46+ security = shared .Security (api_key_auth = api_key_auth )
4347
4448 if server_url is not None :
4549 if url_params is not None :
0 commit comments