Trimble.ID.Testing SDK
The Trimble.ID.Testing SDK is a C# SDK that provides a framework for automating the authentication process with Trimble Identity. As Trimble Identity will no longer support the password grant type, this SDK provides a workaround solution using the authorization grant with headless Chrome.
Getting Started
This SDK is available as a NuGet package from Trimble Artifactory. To add NuGet source see the instructions here.
Installation
To install, use the following command:
dotnet add package Trimble.ID.Testing
Usage
The SDK provides an Authenticator class that can be used to automate the authentication process with Trimble Identity. The Authenticator class requires a Selenium WebDriver instance to interact with the browser.
Test Account Setup
With the transition from hCaptcha to an alternative bot prevention solution, Trimble Identity recommends creating alias accounts using your Trimble email address for testing purposes.
For example, if your email is abc@trimble.com , you can create multiple user accounts such as:
Note: For guidance on creating appropriate test accounts for your scenario, see the Test Accounts Creation Process.
Configuration Options
The SDK provides two constructor overloads for different authentication scenarios:
- Alias Users (@trimble.com.test-google-a.com): Use the Authenticator without identity provider.
- Automation Users (@trimbleautomation.com): Use the Authenticator with identity provider as ‘trimble_automation’.
Basic Example
The following example demonstrates how to use the Authenticator class to automate the authentication process and obtain an access token:
var options = new ChromeOptions();options.AddArgument("headless");using (var driver = new ChromeDriver(".", options)) // assumes the chromedriver.exe is in solution root{ var authenticator = new Authenticator( driver, new Uri("<CONFIGURATION_ENDPOINT>", UriKind.Absolute), "<CONSUMER_KEY>", new [] { "<SCOPES>" };, "<REDIRECT_URI>", "<IDENTITY_PROVIDER>", "<LOGOUT_URI>" );
await authenticator.SignIn("<USERNAME>", "<PASSWORD>"); var accessToken = await authenticator.GetAccessToken();}Constructor Usage Examples
The SDK now provides two distinct constructor options for different test user types:
// Option 1: Authenticator without identity provider (for alias users — @trimble.com.test-google-a.com)var standardAuthenticator = new Authenticator( driver, new Uri("<CONFIGURATION_ENDPOINT>", UriKind.Absolute), "<CONSUMER_KEY>", new [] { "<SCOPES>" }, "<REDIRECT_URI>", "<LOGOUT_URI>");
// Option 2: Authenticator with identity provider (for automation users — @trimbleautomation.com)var automationAuthenticator = new Authenticator( driver, new Uri("<CONFIGURATION_ENDPOINT>", UriKind.Absolute), "<CONSUMER_KEY>", new [] { "<SCOPES>" }, "<REDIRECT_URI>", "trimble_automation", // identity provider parameter "<LOGOUT_URI>");Each constructor uses a different authentication flow tailored to its respective user type and identity provider configuration.
Samples
You can find samples of automated authentication with a headless browser in the Trimble Identity Test Automation SDKs.
To use the samples you must download and unzip the Chrome Driver for Selenium in solution root folder. You can download the Chrome Driver from here.