TokenInterceptor class

The TokenInterceptor class is an implementation of the Dio Interceptor that handles adding authorization headers to requests and refreshing tokens when necessary.

Constructors

TokenInterceptor({required TokenManager tokenManager, required TokenRefreshStrategy tokenRefreshStrategy})
Creates a TokenInterceptor with the given tokenManager and tokenRefreshStrategy.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tokenManager TokenManager
The TokenManager instance used to manage access and refresh tokens.
final
tokenRefreshStrategy TokenRefreshStrategy
The TokenRefreshStrategy instance used to define the strategy for refreshing tokens.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(DioException err, ErrorInterceptorHandler handler) Future
Intercepts errors to handle token refresh if necessary.
onRequest(RequestOptions options, RequestInterceptorHandler handler) Future
Intercepts outgoing requests to add the authorization headers.
onResponse(Response response, ResponseInterceptorHandler handler) → void
Called when the response is about to be resolved.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited