newHeaders method

  1. @override
Future<Map<String, String>> newHeaders(
  1. Map<String, String>? headers
)
override

Adds authorization headers to the client if needed. All methods check if there is a Client as part of the class or if it's null. If it's null it calls this method to check for headers, otherwise it assumes that any authorization information is within the client object

Implementation

@override
Future<Map<String, String>> newHeaders(Map<String, String>? headers) async {
  headers ??= <String, String>{};
  if (client?.credentials.accessToken != null) {
    headers['Authorization'] = 'Bearer ${client!.credentials.accessToken}';
  }
  headers.addAll(authHeaders ?? <String, String>{});
  return headers;
}