toHeaderValue method

Future<String?> toHeaderValue(
  1. String? key
)
inherited

Converts an authentication key to a format that can be used in a transport header. The default implementation encodes and wraps the key in a 'Basic' scheme. (This will automatically be unwrapped again on the server side before being handed to the authentication handler.)

To use a different scheme, override this method. The value must be compliant with the HTTP header format defined in RFC 9110 HTTP Semantics, 11.6.2. Authorization. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization https://httpwg.org/specs/rfc9110.html#field.authorization

Implementation

Future<String?> toHeaderValue(String? key) async {
  if (key == null) return null;
  return wrapAsBasicAuthHeaderValue(key);
}