MCPcopy
hub / github.com/authlib/authlib / extract_basic_authorization

Function extract_basic_authorization

authlib/oauth2/rfc6749/util.py:26–42  ·  view source on GitHub ↗
(headers)

Source from the content-addressed store, hash-verified

24
25
26def extract_basic_authorization(headers):
27 auth = headers.get("Authorization")
28 if not auth or " " not in auth:
29 return None, None
30
31 auth_type, auth_token = auth.split(None, 1)
32 if auth_type.lower() != "basic":
33 return None, None
34
35 try:
36 query = to_unicode(base64.b64decode(auth_token))
37 except (binascii.Error, TypeError):
38 return None, None
39 if ":" in query:
40 username, password = query.split(":", 1)
41 return unquote(username), unquote(password)
42 return query, None

Callers 1

Calls 3

to_unicodeFunction · 0.90
unquoteFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…