class documentation

class Auth:

Known subclasses: httpx._auth.FunctionAuth, httpx.BasicAuth, httpx.DigestAuth

View In Hierarchy

Base class for all authentication schemes.

To implement a custom authentication scheme, subclass Auth and override the .auth_flow() method.

If the authentication scheme does I/O such as disk access or network calls, or uses synchronization primitives such as locks, you should override .sync_auth_flow() and/or .async_auth_flow() instead of .auth_flow() to provide specialized implementations that will be used by Client and AsyncClient respectively.

Async Method async​_auth​_flow Execute the authentication flow asynchronously.
Method auth​_flow Execute the authentication flow.
Method sync​_auth​_flow Execute the authentication flow synchronously.
Class Variable requires​_request​_body Undocumented
Class Variable requires​_response​_body Undocumented
async def async_auth_flow(self, request):

Execute the authentication flow asynchronously.

By default, this defers to .auth_flow(). You should override this method when the authentication scheme does I/O and/or uses concurrency primitives.

Parameters
request:RequestUndocumented
Returns
typing.AsyncGenerator[Request, Response]Undocumented
def auth_flow(self, request):

Execute the authentication flow.

To dispatch a request, yield it:

` yield request `

The client will .send() the response back into the flow generator. You can access it like so:

` response = yield request `

A return (or reaching the end of the generator) will result in the client returning the last response obtained from the server.

You can dispatch as many requests as is necessary.

Parameters
request:RequestUndocumented
Returns
typing.Generator[Request, Response, None]Undocumented
def sync_auth_flow(self, request):

Execute the authentication flow synchronously.

By default, this defers to .auth_flow(). You should override this method when the authentication scheme does I/O and/or uses concurrency primitives.

Parameters
request:RequestUndocumented
Returns
typing.Generator[Request, Response, None]Undocumented
requires_request_body: bool =

Undocumented

requires_response_body: bool =

Undocumented