Kitaru

RenewingTokenAuth

Bearer token auth flow renewing its token through a source on HTTP 401.

Functions

func__init__(self, source) -> None

Initialize the auth flow.

paramself
paramsourceTokenSource

Source producing and renewing the bearer token.

Returns

None
funcasync_auth_flow(self, request) -> AsyncGenerator[httpx.Request, httpx.Response]

Attach a bearer token and retry once with a renewed one on HTTP 401.

A request rejected with HTTP 401 is retried once with a renewed token, unless another caller renewed it first, in which case the retry uses theirs.

paramself
paramrequesthttpx.Request

Outgoing HTTP request.

Returns

collections.abc.AsyncGenerator[httpx.httpx.Request, httpx.httpx.Response]
funcclose(self) -> None

Close the token source.

paramself

Returns

None

On this page