HttpAuthClient class

Constructors

HttpAuthClient({Client? client, required SharedPreferences sharedPreferences, String refreshTokenUrl(String token, JWT decodedToken)?, FutureOr<Map<String, String>> customRefreshTokenResponseParser(String body)?, String? refreshTokenMethod, Duration? maxAge, Duration? refreshTokenTimeout, FutureOr<Map<String, String>> customRefreshTokenRequestBodyFieldsMapper(String refreshToken, String authToken)?, FutureOr<String> customRefreshTokenRequestBodyMapper(String refreshToken, String authToken)?, void onRefreshToken(Map<String, String> tokens)?, void onRefreshTokenFailure(String token, Object exception)?, FutureOr<Map<String, String>> customRefreshTokenCallback(String token, String? refreshToken)?})

Properties

customRefreshTokenCallback FutureOr<Map<String, String>> Function(String token, String? refreshToken)?
This Callback is called whenever a refresh token is needed, this a way to implement any custom logic if user wants to call a 3rd part SDK in order to gain the new token, etc
final
customRefreshTokenRequestBodyMapper FutureOr<String> Function(String refreshToken, String authToken)?
Provide a function to be used in order to use/pass the refresh token to the API endpoint using Client.body
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
onRefreshToken → void Function(Map<String, String> tokens)?
This Callback is called whenever a refresh token have been successfully retrieved It provides access to the retrieved tokens
final
onRefreshTokenFailure → void Function(String token, Object exception)?
This Callback is called whenever a refresh token fail to be retrieved It provides access to the refresh token used & the exception raised
final
refreshTokenMethod String
Defines the 'http' (POST, PUT, etc) method to be used when requesting a new token to the API defaults to 'POST'
getter/setter pair
refreshTokenRequestBodyFieldsMapper FutureOr<Map<String, String>> Function(String refreshToken, String authToken)
Provide a function to be used in order to use/pass the refresh token to the API endpoint using Client.bodyFields
getter/setter pair
refreshTokenResponseParser FutureOr<Map<String, String>> Function(String body)
Defines a custom function to parse the response of your refresh token API, you must return an object with "refreshToken" and "authToken", so it can replace your current session one Example { "auth-token": "YourParsedAuthToken", "auth-refresh-token": "YourParsedRefreshToken" }
getter/setter pair
refreshTokenTimeout Duration
Define a custom period to wait for the refresh token API, after defined period if no response the API call waiting for the token will throw
getter/setter pair
refreshTokenUrl String Function(String token, JWT decodedToken)?
Defines a function to get the URL in which a new token can be requested Defining this property activates the 'refreshToken' mechanism
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sharedPreferences → SharedPreferences
final

Methods

close() → void
Closes the client and cleans up any resources associated with it.
delete(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP DELETE request with the given headers to the given URL.
get(Uri url, {Map<String, String>? headers}) Future<Response>
Sends an HTTP GET request with the given headers to the given URL.
Sends an HTTP HEAD request with the given headers to the given URL.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP PATCH request with the given headers and body to the given URL.
post(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP POST request with the given headers and body to the given URL.
put(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP PUT request with the given headers and body to the given URL.
read(Uri url, {Map<String, String>? headers}) Future<String>
Sends an HTTP GET request with the given headers to the given URL and returns a Future that completes to the body of the response as a String.
readBytes(Uri url, {Map<String, String>? headers}) Future<Uint8List>
Sends an HTTP GET request with the given headers to the given URL and returns a Future that completes to the body of the response as a list of bytes.
send(BaseRequest request) Future<StreamedResponse>
Sends an HTTP request and asynchronously returns the response.
toString() String
A string representation of this object.
inherited

Operators

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