CachingTokenSource class
A token source that caches credentials from any TokenSourceConfigurable using a configurable store.
This wrapper improves performance by avoiding redundant token requests when credentials are still valid. It automatically validates cached tokens and fetches new ones when needed.
The cache will refetch credentials when:
- The cached token has expired (validated via TokenValidator)
- The request options have changed
- The cache has been explicitly invalidated via invalidate
- Implemented types
- Available extensions
Constructors
- CachingTokenSource(TokenSourceConfigurable _wrapped, {TokenStore? store, TokenValidator? validator})
- Initialize a caching wrapper around any token source.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cached(
{TokenStore? store, TokenValidator? validator}) → CachingTokenSource -
Available on TokenSourceConfigurable, provided by the CachedTokenSource extension
Wraps this token source with caching capabilities. -
cachedResponse(
) → Future< TokenSourceResponse?> - Get the cached credentials if one exists.
-
fetch(
TokenRequestOptions options) → Future< TokenSourceResponse> -
override
-
invalidate(
) → Future< void> - Invalidate the cached credentials, forcing a fresh fetch on the next request.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited