You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Propagate API token to custom HTTP clients (#956)
`ApifyClient.with_custom_http_client(token=...)` (and the async twin)
stored the token on the `ApifyClient` instance but never passed it to
the injected HTTP client, so no request carried an `Authorization`
header and every call failed with 401. The documented custom HTTP client
example inherited the bug.
- `with_custom_http_client` now sets `Authorization: Bearer <token>` on
the injected client's default headers, unless the client already has an
auth header configured (checked case-insensitively).
- `HttpClientBase._prepare_request_call` now merges the client's default
headers under the per-request headers, so any custom client using the
helper (including a pre-built `ImpitHttpClient` passed as the custom
client) actually sends them. For the default client the wire behavior is
unchanged, since impit request-level headers replace the identical
client-level ones.
- The HTTPX guide examples now merge `self._headers` before delegating,
and the `HttpClient` ABC docstring states that implementations must send
the default headers with every request.
Regression tests cover the token reaching the wire (custom sync/async
clients and a pre-built tokenless `ImpitHttpClient`) and the no-clobber
semantics for client-configured auth headers.
0 commit comments