token_manager_http 0.1.0
token_manager_http: ^0.1.0 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.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.