(self, request: Request)
| 155 | self._netrc_info = netrc.netrc(file) |
| 156 | |
| 157 | def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]: |
| 158 | auth_info = self._netrc_info.authenticators(request.url.host) |
| 159 | if auth_info is None or not auth_info[2]: |
| 160 | # The netrc file did not have authentication credentials for this host. |
| 161 | yield request |
| 162 | else: |
| 163 | # Build a basic auth header with credentials from the netrc file. |
| 164 | request.headers["Authorization"] = self._build_auth_header( |
| 165 | username=auth_info[0], password=auth_info[2] |
| 166 | ) |
| 167 | yield request |
| 168 | |
| 169 | def _build_auth_header(self, username: str | bytes, password: str | bytes) -> str: |
| 170 | userpass = b":".join((to_bytes(username), to_bytes(password))) |
nothing calls this directly
no test coverage detected