applyToParams method

  1. @override
Future<void> applyToParams(
  1. List<QueryParam> queryParams,
  2. Map<String, String> headerParams
)
override

Apply authentication settings to header and query params.

Implementation

@override
Future<void> applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams,) async {
  if (_accessToken == null) {
    return;
  }

  String accessToken;

  if (_accessToken is String) {
    accessToken = _accessToken;
  } else if (_accessToken is HttpBearerAuthProvider) {
    accessToken = _accessToken!();
  } else {
    return;
  }

  if (accessToken.isNotEmpty) {
    headerParams['Authorization'] = 'Bearer $accessToken';
  }
}