qcs_api_client.client.auth#

Module Contents#

Classes#

QCSAuthConfiguration

This configures how QCSAuth implements its access token refresh mechanism.

QCSAuth

Implements httpx.Auth sync_auth_flow and async_auth_flow.

class qcs_api_client.client.auth.QCSAuthConfiguration#

Bases: pydantic.BaseModel

This configures how QCSAuth implements its access token refresh mechanism.

pre :bool = False#

Pre-emptively refresh access tokens.

When set to True, this will check the access token’s expiration and refresh when necessary before setting the access token in the outgoing Authorization header.

post :bool = True#

Refresh access tokens based on response status code.

When set to True, this will check responses for the status codes configured in post_refresh_statuses. On match, QCSAuth will refresh the access token and retry the request.

post_refresh_statuses :Set[int]#

Response status codes which indicates a possible expired token payload.

This contains a set of HTTP status codes which QCSAuth will check on responses when post is set to True.

exception qcs_api_client.client.auth.QCSAuthRefreshError(response: httpx.Response)#

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

class qcs_api_client.client.auth.QCSAuth(client_configuration: qcs_api_client.client._configuration.QCSClientConfiguration, auth_configuration: QCSAuthConfiguration = None)#

Bases: httpx.Auth

Implements httpx.Auth sync_auth_flow and async_auth_flow.

If the QCSClientConfiguration that initializes this class has a valid TokenPayload on QCSClientConfiguration.credentials, it will set the a refreshed access token as a Bearer token on the Authorization header of outgoing requests.

Access tokens are refreshed via OAuth2 refresh mechanism as indicated by QCSAuthConfiguration.

sync_refresh_token()#
sync_auth_flow(request)#
async async_refresh_token()#
async async_auth_flow(request)#