HttpAuthClient constructor
HttpAuthClient({
- Client? client,
- String refreshTokenUrl(
- String token,
- JWT decodedToken
- FutureOr<
Map< customRefreshTokenResponseParser(String, String> >- String body
- String? refreshTokenMethod,
- Duration? maxAge,
- Duration? refreshTokenTimeout,
- FutureOr<
Map< customRefreshTokenRequestBodyFieldsMapper()?,String, String> > - FutureOr<
String> customRefreshTokenRequestBodyMapper()?, - void onRefreshToken()?,
- void onRefreshTokenFailure()?,
- FutureOr<
Map< customRefreshTokenCallback()?,String, String> > - Future<
Request> customRefreshTokenRequestWrapper(- Request request
Implementation
HttpAuthClient({
http.Client? client,
required this.sharedPreferences,
this.refreshTokenUrl,
FutureOr<Map<String, String>> Function(String body)? customRefreshTokenResponseParser,
String? refreshTokenMethod,
Duration? maxAge,
Duration? refreshTokenTimeout,
FutureOr<Map<String, String>> Function(String refreshToken, String authToken)?
customRefreshTokenRequestBodyFieldsMapper,
this.customRefreshTokenRequestBodyMapper,
this.onRefreshToken,
this.onRefreshTokenFailure,
this.customRefreshTokenCallback,
this.customRefreshTokenRequestWrapper,
}) : assert(
refreshTokenUrl == null || customRefreshTokenCallback == null,
"You cannot define both 'refreshTokenUrl' & 'customRefreshTokenCallback' since the latest will override refresh logic behavior",
) {
this.refreshTokenResponseParser = customRefreshTokenResponseParser ?? _defaultRefreshTokenResponseParser;
this.refreshTokenMethod = "POST";
this.refreshTokenRequestBodyFieldsMapper =
customRefreshTokenRequestBodyFieldsMapper ?? _defaultCustomRefreshTokenRequestBodyFieldsMapper;
this.refreshTokenTimeout = refreshTokenTimeout ?? const Duration(seconds: 15);
_httpClient = client is http.Client ? client : http.Client();
_refreshController = StreamController.broadcast();
}