Version: 1.1.4
Developed against DotNet 6.0.
- DotNet 6.0
- Register a Client-Credentials Client in your AVEVA Data Hub tenant and create a client secret to use in the configuration of this sample. (Video Walkthrough)
- NOTE: This sample only requires the
Tenant Member
role to run successfully - It is strongly advised to not elevate the permissions of a client beyond what is necessary.
- NOTE: This sample only requires the
This sample is meant to be a very simple and straightforward to show how you can use common DotNet library calls to authenticate against ADH. 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:
- Get needed variables
- Get the authentication endpoint from the discovery URL
- Use the client ID and Secret to get the bearer token from the authentication endpoint
- Test it by calling the base tenant endpoint and making sure 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.
AVEVA Data Hub 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 ADH 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"
}
To run this example from the command line once the appsettings.json
is configured, run
cd AuthCC
dotnet restore
dotnet run
To test this example change directories to the test and run
cd AuthCCTest
dotnet restore
dotnet test
Tested against DotNet 6.0
For the main ADH Authentication samples page ReadMe
For the main ADH samples page ReadMe
For the main AVEVA samples page ReadMe