qcs_sdk.client

class QCSClient:

A client providing helper functionality for accessing QCS APIs

def load(profile_name=None):

Create a QCSClient configuration using an environment-based configuration.

Parameters
  • profile_name: The QCS setting's profile name to use. If None, the default value configured in your environment is used.
Raises
  • LoadClientError: If there is an issue loading the profile details from the environment.
def load_with_login(profile_name=None):

Create a QCSClient configuration using an environment-based configuration.

If credentials are not found or stale, a PKCE login redirect flow will be initialized. Note that this opens up a TCP port on your system to accept a browser HTTP redirect, so you should not use this in environments where that is not possible, such as hosted JupyterLab sessions.

Parameters
  • profile_name: The QCS setting's profile name to use. If None, the default value configured in your environment is used.
Raises
  • LoadClientError: If there is an issue loading the profile details from the environment or if the PKCE login flow fails.

See the QCS documentation for more details.

def load_with_login_async(profile_name=None):

Create a QCSClient configuration using an environment-based configuration.

If credentials are not found or stale, a PKCE login redirect flow will be initialized. Note that this opens up a TCP port on your system to accept a browser HTTP redirect, so you should not use this in environments where that is not possible, such as hosted JupyterLab sessions.

Parameters
  • profile_name: The QCS setting's profile name to use. If None, the default value configured in your environment is used.
Raises
  • LoadClientError: If there is an issue loading the profile details from the environment or if the PKCE login flow fails.

See the QCS documentation for more details.

def get_oauth_session_async(self, /):

Get a copy of the OAuth session in an async context.

qvm_url

URL to access the QVM.

quilc_url

URL to access the quilc compiler.

oauth_session

Get a copy of the OAuth session.

api_url

URL to access the QCS API.

grpc_api_url

URL to access the QCS gRPC API.

class OAuthSession:

Manages the OAuth2 authorization process and token lifecycle for accessing the QCS API.

This struct encapsulates the necessary information to request an access token from an authorization server, including the OAuth2 grant type and any associated credentials or payload data.

Fields

  • payload - The OAuth2 grant type and associated data that will be used to request an access token.
  • access_token - The access token currently in use, if any. If no token has been provided or requested yet, this will be None.
  • auth_server - The authorization server responsible for issuing tokens.
def validate(self, /):
def request_access_token(self, /):
def request_access_token_async(self, /):
auth_server

The [AuthServer] that issues the tokens.

payload

The grant type to use to request an access token.

access_token

The access token that is currently in use. None if no token has been requested yet.

class AuthServer:

OAuth 2.0 authorization server.

def default():
client_id

OAuth 2.0 client id.

scopes

OAuth 2.0 scopes to request during authorization requests. If not specified, supported_scopes from the discovery document hosted at issuer will be used. The scope openid is always requested, even if not present in this list.

issuer

OAuth 2.0 issuer URL.

This is the base URL of the identity provider. For Okta, this usually looks like https://example.okta.com/oauth2/default. For Cognito, it might look like https://cognito-idp.us-west-2.amazonaws.com/us-west-2_example.

Note that this is technically distinct from the issuer field in [OidcDiscovery], which is the canonical URI that the identity provider uses to sign and validate tokens, but the OpenID specification requires that they match exactly, and that they match the iss claim in Tokens issued by this identity provider.

class RefreshToken:

A single type containing an access token and an associated refresh token.

refresh_token

The token used to refresh the access token.

class SecretRefreshToken:

An [OAuth 2.0 refresh token][https://oauth.net/2/refresh-tokens/] that is used to obtain a new [SecretAccessToken].

secret

Get the inner secret contents, which removes the protection against accidentally exposing the value.

is_empty

Check if the secret is an empty value

class ClientCredentials:

A pair of Client ID and Client Secret, used to request an OAuth Client Credentials Grant

client_secret

The client secret.

client_id

The client ID

class ExternallyManaged:

A struct that manages access tokens by utilizing a user-provided refresh function.

The [ExternallyManaged] struct allows users to define custom logic for fetching or refreshing access tokens.

class BuildClientError(ClientError):

Errors encountered while building the QCS API client configuration manually.

class ClientError(qcs_sdk.QcsSdkError):

Errors encountered while interacting with a QCS API client.

class RPCQQuilcError(ClientError):

Errors when compiling with RPCQ client.

class TokenError(ClientError):

Errors that can occur when managing authorization tokens.

class LoadClientError(ClientError):

Errors encountered while loading the QCS API client configuration from the environment configuration.