Version: 1.0.0
Developed against Python 3.13.5
- Python 3.9+
- Register a Client-Credentials Client in your CONNECT account and create a client secret to use in the configuration of this sample.
- NOTE: The client requires no permissions or role assignments to run successfully.
- Install required modules:
pip install -r requirements.txt
This sample is meant to be a very simple and straightforward example of how you can use common Python library calls to authenticate against CONNECT using a Client-Credentials Client. In a more complete application you should reuse the bearer token as appropriate and only reissue a new token when it is about to timeout.
The program performs the following steps:
- Get needed variables from the appsettings.json file.
- Use the client ID and Secret to get the bearer token from the authentication endpoint.
- Call the base account details endpoint to ensure a valid response is returned.
The sample is configured using the file appsettings.placeholder.json. Before editing, rename this file to appsettings.json. This repository's .gitignore rules should prevent the file from ever being checked in to any fork or branch, to ensure credentials are not compromised.
CONNECT is secured by obtaining tokens from its identity endpoint. Client credentials clients provide a client application identifier and an associated secret (or key) that are authenticated against the token endpoint. You must replace the placeholders in your appsettings.json file with the authentication-related values and client-credentials client created in your CONNECT account.
{
"Resource": "platform.connect.aveva.com",
"AccountId": "PLACEHOLDER_REPLACE_WITH_ACCOUNT_ID",
"ClientId": "PLACEHOLDER_REPLACE_WITH_APPLICATION_IDENTIFIER",
"ClientSecret": "PLACEHOLDER_REPLACE_WITH_APPLICATION_SECRET",
"Scope": "api"
}To run this example from the command line once the appsettings.json is configured, run
python program.pyTested against Python 3.9.13