RefreshingAuthProvider class
An AuthProvider that fetches a token on demand and refreshes it when the server rejects it.
The building block for any short-lived credential — an OIDC access token, a
cloud workload identity, a session that expires. fetchToken is called on
the first request and again after a 401, and its result is cached in
between, so a long-running updater does not re-authenticate per call.
- Implemented types
Constructors
-
RefreshingAuthProvider(Future<
String> fetchToken(), {String scheme = 'Bearer'}) -
Creates a refreshing provider over
fetchToken.
Properties
-
fetchToken
→ Future<
String> Function() -
Obtains a fresh token.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scheme → String
-
The authorization scheme.
final
Methods
-
close(
) → void -
Releases any resources held.
override
-
headers(
) → Future< Map< String, String> > -
Headers to merge into the next request. Return
const {}for none.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → Future< bool> -
Called when the server answers
401, so a provider backed by a short-lived token can refresh and let the client retry once.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited