You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
465 B

def get_authorization_scheme_param(
authorization_header_value: str | None,
) -> tuple[str, str]:
"""
Parse an ``Authorization`` header value into its scheme and parameter.
Returns a tuple of ``(scheme, credentials)``. If the header is ``None``
or empty, returns ``("", "")``.
"""
if not authorization_header_value:
return "", ""
scheme, _, param = authorization_header_value.partition(" ")
return scheme, param.strip()