Skip to content

Commit c4aec49

Browse files
committed
refactor: Make set_default_authorization on HTTP clients public
1 parent 95486e7 commit c4aec49

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/apify_client/_apify_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def call(self, *, method, url, **kwargs) -> HttpResponse:
254254
"""
255255
instance = cls(token=token, api_url=api_url, api_public_url=api_public_url)
256256
if token is not None:
257-
http_client._set_default_authorization(token) # noqa: SLF001
257+
http_client.set_default_authorization(token)
258258
instance._http_client = http_client
259259
return instance
260260

@@ -616,7 +616,7 @@ async def call(self, *, method, url, **kwargs) -> HttpResponse:
616616
"""
617617
instance = cls(token=token, api_url=api_url, api_public_url=api_public_url)
618618
if token is not None:
619-
http_client._set_default_authorization(token) # noqa: SLF001
619+
http_client.set_default_authorization(token)
620620
instance._http_client = http_client
621621
return instance
622622

src/apify_client/http_clients/_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ def __init__(
145145

146146
self._headers = {**default_headers, **(headers or {})}
147147

148-
def _set_default_authorization(self, token: str) -> None:
149-
"""Set the `Authorization` header from the token, unless an authorization header is already configured."""
148+
def set_default_authorization(self, token: str) -> None:
149+
"""Set the `Authorization` header from the token, unless an authorization header is already configured.
150+
151+
Args:
152+
token: The Apify API token to set as the `Bearer` authorization.
153+
"""
150154
if not any(key.title() == 'Authorization' for key in self._headers):
151155
self._headers['Authorization'] = f'Bearer {token}'
152156

0 commit comments

Comments
 (0)