applyToParams method

  1. @override
Future applyToParams(
  1. QueryParams queryParams,
  2. Map<String, String?> headerParams
)
override

Apply authentication settings to header and query params.

Implementation

@override
Future applyToParams(
    QueryParams queryParams, Map<String, String?> headerParams) async {
  try {
    if (user != null) {
      final token = await user!.getIdToken();
      lastApiKey = token;
      headerParams["Authorization"] = "Bearer $token";
    } else {
      log.fine("No firebase user for request");
    }
  } on fb.FirebaseAuthException {
    throw ApiException.response(401, "Not authenticated");
  } catch (e, stack) {
    throw ApiException.runtimeError(e, stack);
  }
}