AuthOptions class

Configuration options for JWT authentication and automatic token refresh.

Example usage:

AuthOptions(
  refreshTokenEndpoint: '/auth/refresh',
  refreshTokenExecutionType: RefreshTokenStrategy.preemptivelyRefreshBeforeExpiry,
  resolveJwt: (response) => response.data['access_token'],
  resolveRefreshToken: (response) => response.data['refresh_token'],
)

Constructors

AuthOptions({bool useSecureStorage = true, String refreshTokenEndpoint = '', String refreshTokenParameterName = '', RefreshTokenStrategy refreshTokenExecutionType = RefreshTokenStrategy.responseAndRetry, List<String> ignoreAuthForPaths = const [], bool requiresAuth = true, String resolveJwt(dynamic response)?, String resolveRefreshToken(dynamic response)?, dynamic refreshTokenBodyBuilder(String jwt, String refreshToken)?, Map<String, dynamic>? refreshTokenHeadersBuilder(String jwt, String refreshToken)?})
Creates authentication options with the specified configuration.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
ignoreAuthForPaths → List<String>
API paths that should skip authentication checks.
final
refreshTokenBodyBuilder → dynamic Function(String jwt, String refreshToken)?
Custom builder for the refresh token request body.
final
refreshTokenEndpoint → String
The API endpoint for refreshing tokens (e.g., /auth/refresh).
final
refreshTokenExecutionType → RefreshTokenStrategy
The strategy for handling token refresh.
final
refreshTokenHeadersBuilder → Map<String, dynamic>? Function(String jwt, String refreshToken)?
Custom builder for the refresh token request headers.
final
refreshTokenParameterName → String
The parameter name for the refresh token in the request body.
final
requiresAuth → bool
Whether authentication is required for requests by default.
final
resolveJwt → String Function(dynamic response)?
Callback to extract the new JWT from the refresh token response.
final
resolveRefreshToken → String Function(dynamic response)?
Callback to extract the new refresh token from the refresh token response.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
useSecureStorage → bool
Whether to use secure (encrypted) storage for tokens.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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