token_manager_http 0.1.1
token_manager_http: ^0.1.1 copied to clipboard
A package:http client that attaches token_manager tokens to requests and replays a request once after an auth failure.
Changelog #
0.1.1 #
Internal refactor and documentation fixes; no behaviour change.
- The client defaults moved out of
HttpTokenClientinto their own internal class. The public API and behaviour are unchanged. - Docs: exact wording on which requests get tokens (
shouldAuthorize) and which are replayed, including requests that cannot be replayed. - Docs: the rejected response body is buffered without a size cap, and its headers are copied.
0.1.0 #
Initial release of the package:http adapter for token_manager.
HttpTokenClient<T>, aBaseClientover an innerClientthat sends every request with the headers built from the tokens of aTokenManager<T>(by defaultAuthorization: Bearer <accessToken>forTokenSet) and never changes the caller's request. A request thatshouldAuthorizedeclines, such as a login, is sent unchanged without tokens.- A streamed or multipart request is sent once. When the server rejects it
(
isAuthFailure, status 401 by default) the response is returned as is and the rejected tokens are reported to the manager, so the next request gets new ones. - A
RequestorAbortableRequestthat the server rejects is sent once more with the tokensTokenManager.authorizeprovides; concurrent rejections share one refresh. The rejected body is read first so its connection is released, and a rejection that is not replayed is returned with its body. close()closes the inner client once and leaves the manager open; a request afterclose()fails with aClientException.