datalad_next.utils.parse_www_authenticate

datalad_next.utils.parse_www_authenticate(hdr: str) dict[source]

Parse HTTP www-authenticate header

This helper uses requests utilities to parse the www-authenticate header as represented in a requests.Response instance. The header may contain any number of challenge specifications.

The implementation follows RFC7235, where a challenge parameters set is specified as: either a comma-separated list of parameters, or a single sequence of characters capable of holding base64-encoded information, and parameters are name=value pairs, where the name token is matched case-insensitively, and each parameter name MUST only occur once per challenge.

Returns:

Keys are casefolded challenge labels (e.g., 'basic', 'digest'). Values are: None (no parameter), str (a token68), or dict (name/value mapping of challenge parameters)

Return type:

dict