Skip to content

Repository files navigation

CONNECT Client Credentials Python Sample

Version: 1.0.0

Developed against Python 3.13.5

Requirements

  • 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

About this sample

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:

  1. Get needed variables from the appsettings.json file.
  2. Use the client ID and Secret to get the bearer token from the authentication endpoint.
  3. Call the base account details endpoint to ensure a valid response is returned.

Configuring the sample

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"
}

Running the sample

To run this example from the command line once the appsettings.json is configured, run

python program.py

Tested against Python 3.9.13

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages