MCPcopy Index your code
hub / github.com/python-websockets/websockets / build_authorization_basic

Function build_authorization_basic

src/websockets/headers.py:575–586  ·  view source on GitHub ↗

Build an ``Authorization`` header for HTTP Basic Auth. This is the reverse of :func:`parse_authorization_basic`.

(username: str, password: str)

Source from the content-addressed store, hash-verified

573
574
575def build_authorization_basic(username: str, password: str) -> str:
576 """
577 Build an ``Authorization`` header for HTTP Basic Auth.
578
579 This is the reverse of :func:`parse_authorization_basic`.
580
581 """
582 # https://datatracker.ietf.org/doc/html/rfc7617#section-2
583 assert ":" not in username
584 user_pass = f"{username}:{password}"
585 basic_credentials = base64.b64encode(user_pass.encode()).decode()
586 return "Basic " + basic_credentials

Calls 2

decodeMethod · 0.45
encodeMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…