Authentification

The ParityOS cloud server employs token-based authentication and provides, depending on the operational environment, two primary classes for credential management via the HTTPClient. After successful client authentication, the user can create service instances and submit jobs to the services.

Prerequisites: Account set up

Before utilizing the cloud-based quantum services associated with the ParityOS Python client, you must have a registered and active ParityOS account. Once your account has been successfully activated, you can connect to the services using the unique credentials (username and password) associated with your profile. These credentials will serve as the basis for the authentication via the ParityOS HTTPClient methods detailed below.

Automated Authentication: EnvVarAuth

For production environments, CI/CD pipelines or automated scripts, EnvVarAuth is the recommended approach. This class retrieves credentials directly from system environment variables, preventing the need for manual input. The client will fail if these variables are not configured correctly.

Required environment variables:

  • PARITYOS_USER

  • PARITYOS_PASS

Note

The names of the environment variables that EnvVarAuth will query can be set as initialization parameters. They default to PARITYOS_USER and PARITYOS_PASS.

Usage:

  1. Set the variables before running the application:

export PARITYOS_USER="your_username"
export PARITYOS_PASS="your_password"
  1. Create the client:

from parityos.services.authentication import EnvVarAuth
from parityos.services.client import HTTPClient

# fetches credentials from `PARITYOS_USER` and `PARITYOS_PASS`
client1 = HTTPClient(authenticator=EnvVarAuth())
# fetches credentials from `USER` and `PASS`
client2 = HTTPClient(authenticator=EnvVarAuth(username_env_var="USER", password_env_var="PASS"))

Interactive Authentication: InteractiveAuth

For local development InteractiveAuth provides a flexible interface. It first attempts to retrieve the user credentials using the environment variables. If they are missing, it interactively prompts the user to provide them via the terminal.

Usage:

from parityos.services.authentication import InteractiveAuth
from parityos.services.client import HTTPClient

# will be asked for username and password
client1 = HTTPClient(authenticator=InteractiveAuth())
# will be asked for password for user "user"
client2 = HTTPClient(authenticator=InteractiveAuth(username="user"))