TokenKeeperInterceptor constructor
TokenKeeperInterceptor({})
Creates an interceptor.
keeperis the source of tokens.diois used to retry the original request after a refresh. Pass the sameDioinstance the interceptor is attached to.headerName/schemecustomise the auth header (defaults produceAuthorization: Bearer <token>).shouldRefreshOnlets you treat additional status codes (e.g.419) as auth failures.onRefreshFailedis invoked when a 401-triggered refresh fails. Use it to navigate directly to login from the interceptor layer.
Implementation
TokenKeeperInterceptor({
required this.keeper,
required this.dio,
this.headerName = 'Authorization',
this.scheme = 'Bearer',
bool Function(Response<dynamic>? response)? shouldRefreshOn,
this.onRefreshFailed,
this.onTokenAttached,
}) : _shouldRefreshOn = shouldRefreshOn ?? _defaultShouldRefreshOn;