pub async fn error_message_from_response(
response: Response,
default_message: &str,
) -> StringExpand description
Extract the most meaningful error message from an HTTP response. This is useful for handling OAuth2 / OpenID Connect Bearer errors
Extraction order:
- If the
WWW-Authenticateheader exists and contains a Bearer error:- Return
error_descriptionif present - Else return
errorif present - Else join all string values in the header
- Return
- If no usable info is found in the header:
- Return the response body text
- If body cannot be read, return
default_message