Skip to main content

extract_header_bearer_token

Function extract_header_bearer_token 

Source
pub fn extract_header_bearer_token(
    headers: &HeaderMap,
) -> Result<Option<&str>, Error>
Expand description

Extract raw Bearer credentials from the Authorization field.

Scheme matching is ASCII case-insensitive and requires at least one ASCII space. Only the first required space is consumed; any additional spaces are preserved in the returned credentials. Bearer therefore produces Some(""). A missing field, another scheme, or a scheme without the required space returns None. Duplicate or non-text Authorization fields return an error before scheme matching. This function does not validate the token syntax or authenticate it, and the returned credential is sensitive. See Bearer usage in RFC 6750, Section 2.1.