Build an ``Authorization`` header for HTTP Basic Auth. This is the reverse of :func:`parse_authorization_basic`.
(username: str, password: str)
| 573 | |
| 574 | |
| 575 | def 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 |
searching dependent graphs…