AuthTokenInterceptor class

A custom interceptor for handling token refresh and request retries. This should be the first interceptor added to DIO as interceptors are executed in FIFO

Constructors

AuthTokenInterceptor(Dio dio, String refreshTokenKey, String accessTokenKey, String refreshTokenUrl, TokenStorage tokenStorage)
Constructs a new instance of AuthTokenInterceptor.

Properties

accessTokenKey String
final
dio → Dio
final
failedRequests List<Map>
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
refreshTokenKey String
final
refreshTokenUrl String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tokenStorage TokenStorage
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(DioException err, ErrorInterceptorHandler handler) Future<void>
Called when an exception was occurred during the request.
onRequest(RequestOptions options, RequestInterceptorHandler handler) Future<void>
Called when the request is about to be sent.
onResponse(Response response, ResponseInterceptorHandler handler) → void
Called when the response is about to be resolved.
inherited
refreshToken(DioException err, ErrorInterceptorHandler handler) Future<void>
Performs the token refresh operation. err: The Dio error that triggered the token refresh. handler: The error interceptor handler.
retryRequests(Dio retryDio, String token) Future<void>
Retries failed requests with the updated access token.
toString() String
A string representation of this object.
inherited

Operators

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