BaseAuthInterceptor class abstract

Base interceptor for injecting auth tokens and handling 401 refreshes.

Inheritance

Constructors

BaseAuthInterceptor({required Dio dio})
Creates a BaseAuthInterceptor with dio for retrying requests.

Properties

dio → Dio
The Dio client instance used to retry requests upon token refresh.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tokenHeaderName → String
The header name used for authorization. Defaults to 'Authorization'.
no setter

Methods

formatToken(String token) → String
Formats the token string. Defaults to prefixing with 'Bearer'.
getAccessToken() → Future<String?>
Retrieves the current access token.
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.
override
onRequest(RequestOptions options, RequestInterceptorHandler handler) → Future<void>
Called when the request is about to be sent.
override
onResponse(Response response, ResponseInterceptorHandler handler) → void
Called when the response is about to be resolved.
inherited
refreshToken() → Future<bool>
Requests a token refresh. Returns true if the refresh succeeded.
toString() → String
A string representation of this object.
inherited

Operators

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