MCPcopy
hub / github.com/encode/httpx / auth_flow

Method auth_flow

httpx/_auth.py:157–167  ·  view source on GitHub ↗
(self, request: Request)

Source from the content-addressed store, hash-verified

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)))

Callers

nothing calls this directly

Calls 1

_build_auth_headerMethod · 0.95

Tested by

no test coverage detected