MCPcopy
hub / github.com/authlib/authlib / _parse_authorization_header

Function _parse_authorization_header

authlib/oauth1/rfc5849/wrapper.py:90–106  ·  view source on GitHub ↗

Parse an OAuth authorization header into a list of 2-tuples.

(headers)

Source from the content-addressed store, hash-verified

88
89
90def _parse_authorization_header(headers):
91 """Parse an OAuth authorization header into a list of 2-tuples."""
92 authorization_header = headers.get("Authorization")
93 if not authorization_header:
94 return [], None
95
96 auth_scheme = "oauth "
97 if authorization_header.lower().startswith(auth_scheme):
98 items = parse_http_list(authorization_header[len(auth_scheme) :])
99 try:
100 items = parse_keqv_list(items).items()
101 auth_params = [(unescape(k), unescape(v)) for k, v in items]
102 realm = dict(auth_params).get("realm")
103 return auth_params, realm
104 except (IndexError, ValueError):
105 pass
106 raise ValueError("Malformed authorization header")
107
108
109def _parse_oauth_params(query_params, body_params, auth_params):

Callers 1

__init__Method · 0.85

Calls 2

unescapeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…