Supported Python versions
The SDK supports Python 3.10 and later. If your project uses SDK version 0.2.x, check the migration notes in the Python SDK repository before updating to version 0.3.x or later.Installation and update
Install the SDK package:Initialization and authentication
For server-to-server communication, use a service account to authenticate SDK requests. The SDK uses the service account credentials to generate a JSON Web Token, exchange it for an IAM token and refresh the IAM token in the background.For local usage, authenticate SDK requests by using an IAM token, CLI configuration or a credentials file. For more information, see the Python SDK repository.
- Create a service account.
-
Create a private and public key pair:
This command creates the
private.pemandpublic.pemfiles in the current directory. -
Upload the public key to create an authorized key:
In the command, specify the service account ID.
-
Initialize the SDK with the private key file:
In the script, set the following parameters:
<application_name>/<application_version_or_comment>: Application or library that calls the SDK. The version or comment is optional.<private_key_file_path>: Path to the private key file, for exampleprivate.pem.<public_key_ID>: ID of the public key generated for the service account.<service_account_ID>: ID of your service account.
SDKconstructor initializes the SDK and uses the service account private key file to authenticate requests. Theuser_agent_prefixargument adds a prefix to the User-Agent header sent with each request. Useuser_agent_prefixto identify your application in the list of requests.