Skip to content

AVEVA/sample-adh-authentication_client_credentials_simple-rust

Repository files navigation

CONNECT data services Client Credentials Rust Sample

Version: 1.0.7

Build Status

Developed against Rust 1.24.3.

Requirements

About this sample

This sample is meant to be very simple and straightforward to show how you can use common Rust library calls to authenticate against Cds. 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.

Steps:

  1. Get needed variables
  2. Get the token (authentication) endpoint from the discovery URL
  3. Use the Client ID and Secret to get a bearer token from the token endpoint
  4. Test it by calling the base tenant endpoint, ensuring 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 data services 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 from your tenant and a client-credentials client created in your Cds tenant.

{
  "Resource": "https://uswe.datahub.connect.aveva.com",
  "ApiVersion": "v1",
  "TenantId": "PLACEHOLDER_REPLACE_WITH_TENANT_ID",
  "ClientId": "PLACEHOLDER_REPLACE_WITH_APPLICATION_IDENTIFIER",
  "ClientSecret": "PLACEHOLDER_REPLACE_WITH_APPLICATION_SECRET"
}

Running the sample

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

cargo run

Testing the sample

To run the unit test for this sample, run

cargo test

Tested against Rust 1.24.3

For the main Cds Authentication samples page ReadMe
For the main Cds samples page ReadMe
For the main AVEVA samples page ReadMe

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages