Attaches HTTP Basic Authentication to the given Request object.
| 83 | |
| 84 | |
| 85 | class HTTPBasicAuth(AuthBase): |
| 86 | """Attaches HTTP Basic Authentication to the given Request object.""" |
| 87 | |
| 88 | username: bytes | str |
| 89 | password: bytes | str |
| 90 | |
| 91 | @overload |
| 92 | def __init__(self, username: str, password: str) -> None: ... |
| 93 | @overload |
| 94 | def __init__(self, username: bytes, password: bytes) -> None: ... |
| 95 | |
| 96 | def __init__(self, username: bytes | str, password: bytes | str) -> None: |
| 97 | self.username = username |
| 98 | self.password = password |
| 99 | |
| 100 | def __eq__(self, other: object) -> bool: |
| 101 | return all( |
| 102 | [ |
| 103 | self.username == getattr(other, "username", None), |
| 104 | self.password == getattr(other, "password", None), |
| 105 | ] |
| 106 | ) |
| 107 | |
| 108 | def __ne__(self, other: Any) -> bool: |
| 109 | return not self == other |
| 110 | |
| 111 | def __call__(self, r: PreparedRequest) -> PreparedRequest: |
| 112 | r.headers["Authorization"] = _basic_auth_str(self.username, self.password) |
| 113 | return r |
| 114 | |
| 115 | |
| 116 | class HTTPProxyAuth(HTTPBasicAuth): |