Skip to content

Trimble.ID

Trimble.ID

Represents Trimble identity access token with expiry information.

Creates a new instance of AccessToken using the provided accessToken and expiresOn.

Name Type Description
accessToken System.String The access token value.
expiresOn System.DateTimeOffset The access token expiry date.

Gets the time when the provided token expires.

Get the access token value.

Inherit from parent.

This method has no parameters.

Inherit from parent.

This method has no parameters.

Trimble.ID

A token provider based on the OAuth Authorization Code grant type

const string CONSUMER_KEY = "APPLICATION_CONSUMER_KEY";
const string CONSUMER_SECRET = "APPLICATION_CONSUMER_SECRET";
const string REDIRECT_URL = "http://localhost:8080";
const string AUTHORIZATION_ENDPOINT = "https://id.trimble.com/oauth/authorize";
const string TOKEN_ENDPOINT = "https://id.trimble.com/oauth/token?tenantDomain=trimble.com";
IEndpointProvider endpointProvider = new FixedEndpointProvider(new Uri(AUTHORIZATION_ENDPOINT, UriKind.Absolute), new Uri(TOKEN_ENDPOINT, UriKind.Absolute));
ITokenProvider tokenProvider = new AuthorizationCodeGrantTokenProvider(endpointProvider, CONSUMER_KEY, REDIRECT_URL)
.WithConsumerSecret(CONSUMER_SECRET)
.WithScopes(new[] string { "scope" });
var token = await tokenProvider.RetrieveToken();

Implements ITokenProvider

#ctor(endpointProvider,clientId,redirectUrl,productName) constructor

Section titled “#ctor(endpointProvider,clientId,redirectUrl,productName) constructor”

Public constructor for AuthorizationCodeGrantTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity authorization and token endpoints
clientId System.String The client Id for the calling application
redirectUrl System.String The URL to which Trimble Identity should redirect after successfully authenticating a user
productName System.String The product name of the consuming application (Optional).

#ctor(endpointProvider,clientId,redirectUri,productName) constructor

Section titled “#ctor(endpointProvider,clientId,redirectUri,productName) constructor”

Public constructor for AuthorizationCodeGrantTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity authorization and token endpoints
clientId System.String The client Id for the calling application
redirectUri System.Uri The URL to which Trimble Identity should redirect after successfully authenticating a user
productName System.String The product name of the consuming application (Optional).

This is provided as a convienence method, be aware it is critical to ensure that redirectUri.AbsoluteUri matches the value specified when creating the application

Return a redirect URL to log out of all Trimble Identity applications

A Task that resolves to the value of the redirect URL on completion

Name Type Description
state System.String An optional state parameter that will be passed back to the caller via the redirect URL
Name Description
System.InvalidOperationException Thrown when an ID token is not available

Get a redirect URL for Trimble Identity

An awaitable Task that resolves to the redirect URL

Name Type Description
state System.String An optional state parameter that will be passed back to the caller via the redirect URL
prompt System.Boolean This parameter is optional and determines whether to display the login UI. The default value is True.
Name Description
Trimble.ID.AuthorizationFailedException Thrown when an authorization endpoint is not provided by the endpoint provider

Validate the code parameter passed to the application by Trimble Identity

True if the code is valid

Name Type Description
code System.String The code query string from the URL
Name Description
Trimble.ID.AuthorizationFailedException Thrown when failed to validate the given auth code

Validate the query parameters passed back to the application by Trimble Identity

True if the query string is valid

Name Type Description
query System.String The query string from the URL
Name Description
Trimble.ID.AuthorizationFailedException Thrown when failed to validate the given auth code

WithIdentityProvider(identityProvider) method

Section titled “WithIdentityProvider(identityProvider) method”

Add Identity Provider to the authorization URL

Name Type Description
identityProvider System.String An optional parameter which specifies a federated identity provider that should be used to authenticate

WithLogoutRedirect(logoutRedirectUrl) method

Section titled “WithLogoutRedirect(logoutRedirectUrl) method”

Add Redirect URL to an AuthorizationCodeGrantTokenProvider

Name Type Description
logoutRedirectUrl System.String A URL which the browser will return to after logout

This URL must match one of the URLs configured for the calling client

WithLogoutRedirect(logoutRedirectUri) method

Section titled “WithLogoutRedirect(logoutRedirectUri) method”

Add Redirect URL to an AuthorizationCodeGrantTokenProvider

Name Type Description
logoutRedirectUri System.Uri A URL which the browser will return to after logout

This URL must match one of the URLs configured for the calling client

Fluent extension for adding scopes

Name Type Description
scopes System.Collections.Generic.IEnumerable{System.String} The requested scopes

Trimble.ID

An exception class raised for errors in authorizing client requests.

Creates a new AuthorizationFailedException with the specified message.

Name Type Description
message System.String

Creates a new AuthorizationFailedException with the specified message.

Name Type Description
message System.String The message describing the authorization failure.
innerException System.Exception The exception underlying the authorization failure.

Trimble.ID

A HttpClient provider for APIs using Bearer token authorization

const string API_BASE_URL = "https://api-usw2.trimblepaas.com/data_ocean-v1.0";
const string TOKEN = "USER_OR_APPLICATION_ACCESS_TOKEN";
ITokenProvider tokenProvider = new FixedTokenProvider(TOKEN);
IHttpClientProvider httpclientProvider = new BearerTokenHttpClientProvider(tokenProvider, new Uri(API_BASE_URL, UriKind.Absolute));
var httpClient = await httpclientProvider.RetrieveClient();

Implements IHttpClientProvider

#ctor(tokenProvider,baseAddress,productName) constructor

Section titled “#ctor(tokenProvider,baseAddress,productName) constructor”

Public constructor for BearerTokenHttpClientProvider class

Name Type Description
tokenProvider Trimble.ID.ITokenProvider A token provider that provides the access token for the authenticated application or user
baseAddress System.Uri The base address for the API that will be called
productName System.String The product name of the consuming application (Optional).

Implements IHttpClientProvider

Gets the client ID.

Gets or sets the logger for this HTTP client provider

Gets the client ID asynchronously.

This method has no parameters.

Retrieves a preconfigured HttpClient to access a given API

A Task that resolves to the value of the preconfigured HttpClient on completion

This method has no parameters.

Name Description
System.Exception Thrown when a token is not provided by the token provider

Sets the HTTP message handler to be used by the client provider.

Name Type Description
handler System.Net.Http.HttpMessageHandler The HTTP message handler to be set.

Trimble.ID

A token provider based on the OAuth Client Credential grant type

const string CLIENT_ID = "APPLICATION_CLIENT_ID";
const string CLIENT_SECRET = "APPLICATION_CLIENT_SECRET";
const string TOKEN_ENDPOINT = "https://id.trimble.com/oauth/token?tenantDomain=trimble.com";
IEndpointProvider endpointProvider = new FixedEndpointProvider(tokenEndpoint: new Uri(TOKEN_ENDPOINT, UriKind.Absolute));
ITokenProvider tokenProvider = new ClientCredentialTokenProvider(endpointProvider, CLIENT_ID, CLIENT_SECRET).WithScopes(new[] string { "scope" });
var token = await tokenProvider.RetrieveToken();

Implements ITokenProvider

#ctor(endpointProvider,consumerKey,consumerSecret,productName) constructor

Section titled “#ctor(endpointProvider,consumerKey,consumerSecret,productName) constructor”

Public constructor for ClientCredentialTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKey System.String The consumer key for the calling application
consumerSecret System.String The consumer secret for the calling application
productName System.String The product name of the consuming application (Optional).

Implements ITokenProvider

Retrieves an access token for the application

A Task that resolves to the value of the access token on completion

This method has no parameters.

Name Description
Trimble.ID.AuthorizationFailedException Thrown when a call to the token endpoint fails to obtain token

Inherit from parent.

This method has no parameters.

Fluent extension for adding scopes

Name Type Description
scopes System.Collections.Generic.IEnumerable{System.String} The requested scopes

Trimble.ID

Represents the response of DeviceAuthorization.

Gets or sets the device code.

Gets or sets the expiration time in seconds.

Gets or sets the interval.

Gets or sets the user code.

Gets or sets the verification URI.

Gets or sets the complete verification URI.

Trimble.ID

Represents the authorization status of a device.

Access denied authorization status.

Access granted authorization status.

Authorization pending authorization status.

Code expired authorization status.

No authorization status.

Slow down authorization status.

Trimble.ID

A token provider based on the Device Authorization grant type

Implements ITokenProvider

#ctor(endpointProvider,clientId,productName) constructor

Section titled “#ctor(endpointProvider,clientId,productName) constructor”

Public constructor for DeviceAuthorizationTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity token endpoint
clientId System.String The consumer key for the calling application
productName System.String The product name of the consuming application (Optional).

Request authorization

DeviceAuthorizationResponse that contains user code, device code and verification uri

This method has no parameters.

Name Description
System.Exception Thrown when a call to the device authorization endpoint fails

PerformTokenRequest(deviceCode,pollInterval,timeout,onCallback,cancellationToken) method

Section titled “PerformTokenRequest(deviceCode,pollInterval,timeout,onCallback,cancellationToken) method”

Performs token request

Name Type Description
deviceCode System.String Device code to perform token request
pollInterval System.Int32 Time interval between each request
timeout System.Int32 The maximum time until the request times out
onCallback System.Action{Trimble.ID.DeviceAuthorizationStatus} Callback method to check whether the device has been authorized
cancellationToken System.Threading.CancellationToken Cancellation token
Name Description
System.TimeoutException Thrown when a token request times out
Trimble.ID.AuthorizationFailedException Thrown when a call to device authoiration fails

Retrieves a id token for the application

A Task that resolves to the value of the ID token on completion

This method has no parameters.

Retrieves a refresh token for the application

A Task that resolves to the value of the refresh token on completion

This method has no parameters.

Retrieves an access token for the application

A Task that resolves to the value of the access token on completion

This method has no parameters.

Name Description
Trimble.ID.TokenRefreshException Thrown when a call to the token endpoint fails

Inherit from parent.

This method has no parameters.

Fluent extension for adding client secret

Name Type Description
clientSecret System.String The client secret for the calling application

Fluent extension for adding scopes

Name Type Description
scopes System.Collections.Generic.IEnumerable{System.String} The requested scopes

Trimble.ID

Represents the device token error response.

Gets or sets the error message.

Gets or sets the error description.

Trimble.ID

Wrapper for IPersistantStorage that adds encryption functionality

Constructor

This constructor has no parameters.

Combines the secret with additional entropy

This method has no parameters.

Retrieve a named value from persistant storage

This method has no parameters.

Remove a named value from persistant storage

This method has no parameters.

Store a named value in persistant storage

This method has no parameters.

Trimble.ID

The Authorization Error messages.

The error message.

The error message.

The error message.

The error message.

The error message.

The error message.

Error message for when refresh token is null or empty

Error message for failed token refresh

Trimble.ID

An endpoint provider that returns fixed values

const string AUTHORIZATION_ENDPOINT = "https://id.trimble.com/oauth/authorize";
const string TOKEN_ENDPOINT = "https://id.trimble.com/oauth/token?tenantDomain=trimble.com";
IEndpointProvider endpointProvider = new FixedEndpointProvider()
.WithAuthorizationEndpoint(new Uri(AUTHORIZATION_ENDPOINT, UriKind.Absolute))
.WithTokenEndpoint(new Uri(TOKEN_ENDPOINT, UriKind.Absolute));
var authorizationEndpoint = await endpointProvider.RetrieveAuthorizationEndpoint();
var tokenEndpoint = await endpointProvider.RetrieveTokenEndpoint();

Implements IEndpointProvider

Public constructor for FixedEndpointProvider class

Name Type Description
productName System.String The product name of the consuming application (Optional).

Protected copy constructor for FixedEndpointProvider class

This constructor has no parameters.

#ctor(authorizationEndpoint,tokenEndpoint,userInfoEndpoint,tokenRevocationEndpoint,jwksEndpoint,endSessionEndpoint,deviceAuthorizationEndpoint) constructor

Section titled “#ctor(authorizationEndpoint,tokenEndpoint,userInfoEndpoint,tokenRevocationEndpoint,jwksEndpoint,endSessionEndpoint,deviceAuthorizationEndpoint) constructor”

Public constructor for FixedEndpointProvider class

Name Type Description
authorizationEndpoint System.Uri The URL for the Trimble Identity authorization endpoint
tokenEndpoint System.Uri The URL for the Trimble Identity token endpoint
userInfoEndpoint System.Uri The URL for the Trimble Identity user information endpoint
tokenRevocationEndpoint System.Uri The URL for the Trimble Identity token revocation endpoint, if not supplied this is computed relative to the token endpoint
jwksEndpoint System.Uri The URL for the Trimble Identity JSON web keyset endpoint
endSessionEndpoint System.Uri The URL for the Trimble Identity end session endpoint, if not supplied this is computed relative to the token endpoint
deviceAuthorizationEndpoint System.Uri The URL for the Trimble Identity device authorization endpoint

Implements IEndpointProvider

Retrieves a URL for the Trimble Identity authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

RetrieveDeviceAuthorizationEndpoint() method

Section titled “RetrieveDeviceAuthorizationEndpoint() method”

Retrieves a URL for the Trimble Identity device authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity token revocation endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity JSON web keyset endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity token endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity token revocation endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity user information endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

WithAuthorizationEndpoint(authorizationEndpoint) method

Section titled “WithAuthorizationEndpoint(authorizationEndpoint) method”

Add an authorization endpoint

A new instance of a FixedEndpointProvider

Name Type Description
authorizationEndpoint System.Uri The URL for the Trimble Identity authorization endpoint

WithDeviceAuthorizationEndpoint(deviceAuthorizationEndpoint) method

Section titled “WithDeviceAuthorizationEndpoint(deviceAuthorizationEndpoint) method”

A new instance of a FixedEndpointProvider

Name Type Description
deviceAuthorizationEndpoint System.Uri The URL for the Trimble Identity device authorization endpoint

WithEndSessionEndpoint(endSessionEndpoint) method

Section titled “WithEndSessionEndpoint(endSessionEndpoint) method”

Add an end session endpoint

A new instance of a FixedEndpointProvider

Name Type Description
endSessionEndpoint System.Uri The URL for the Trimble Identity end session endpoint, if not supplied this is computed relative to the token endpoint

Add a JWKS endpoint

A new instance of a FixedEndpointProvider

Name Type Description
jwksEndpoint System.Uri The URL for the Trimble Identity JSON web keyset endpoint

Add a token endpoint

A new instance of a FixedEndpointProvider

Name Type Description
tokenEndpoint System.Uri The URL for the Trimble Identity token endpoint

WithTokenRevocationEndpoint(tokenRevocationEndpoint) method

Section titled “WithTokenRevocationEndpoint(tokenRevocationEndpoint) method”

Add a token revocation endpoint

A new instance of a FixedEndpointProvider

Name Type Description
tokenRevocationEndpoint System.Uri The URL for the Trimble Identity token revocation endpoint, if not supplied this is computed relative to the token endpoint

WithUserInfoEndpoint(userInfoEndpoint) method

Section titled “WithUserInfoEndpoint(userInfoEndpoint) method”

Add a user info endpoint

A new instance of a FixedEndpointProvider

Name Type Description
userInfoEndpoint System.Uri The URL for the Trimble Identity user information endpoint

Trimble.ID

A keyset provider that returns a fixed keyset

var keyset = new Dictionary<string, RSACryptoServiceProvider>)();
var key = new RSACryptoServiceProvider();
key.ImportParameters(new RSAParameters()
{
Modulus = Base64Url.Decode("nzyis1ZjfNB0bBgK..."),
Exponent = Base64Url.Decode("AQAB")
});
keyset.Add("31824ffd-777e-458a-a3b6-2808f64a0bdd", key);
IKeySetProvider keysetProvider = new FixedKeySetProvider(keyset);
var keyset = await keysetProvider.RetrieveKeySet();

Implements IKeysetProvider

Public constructor for FixedKeySetProvider class

Name Type Description
keyset System.Collections.Generic.Dictionary{System.String,System.Security.Cryptography.RSACryptoServiceProvider} A dictionary of named keys

Implements IKeySetProvider

Retrieves an dictionary of named keys

A Task that resolves to a dictionary of named keys on completion

This method has no parameters.

Trimble.ID

A token provider that returns a fixed token

const string TOKEN = "USER_OR_APPLICATION_ACCESS_TOKEN";
ITokenProvider tokenProvider = new FixedTokenProvider(TOKEN);
var token = await tokenProvider.RetrieveToken();

Implements ITokenProvider

Public constructor for FixedTokenProvider class

Name Type Description
token System.String The fixed token to return
productName System.String The product name of the consuming application (Optional).

Implements ITokenProvider

#ctor(token,expiresIn,productName) constructor

Section titled “#ctor(token,expiresIn,productName) constructor”

Public constructor for FixedTokenProvider class

Name Type Description
token System.String The fixed token to return
expiresIn System.Int32 The expiration time of the token in seconds
productName System.String The product name of the consuming application (Optional).

Implements ITokenProvider

Retrieves an access token for the user or application

A Task that resolves to the value of the access token on completion

This method has no parameters.

Inherit from parent.

This method has no parameters.

Trimble.ID

Common interface for authenticators

Get the logged in state

Get the token provider for this authenticator

This token provider can be used with other SDK components

Get the token provider for this authenticator

This token provider can be used with other SDK components

Validates the ID token and returns user claims

User claims from the ID token

This method has no parameters.

Login(silent,timeoutInMs,cancellationToken) method

Section titled “Login(silent,timeoutInMs,cancellationToken) method”

Log the user in

true if the user was successfully logged in

Name Type Description
silent System.Boolean true if no UI should be shown i.e. prompt=none
timeoutInMs System.Int32 Specify the length of time that client waits for a login response when making a login attempt. The default timeout value is 3 minutes.
cancellationToken System.Threading.CancellationToken Token which can be used to cancel the task.
Name Description
System.TimeoutException Login operation has timed out after waiting for specified time.
System.Threading.Tasks.TaskCanceledException The task is cancelled for specified time.

Logout(singleSignOut,cancellationToken) method

Section titled “Logout(singleSignOut,cancellationToken) method”

Log the user out

true if the user was successfully logged out

Name Type Description
singleSignOut System.Boolean true if the single sign in session should be terminated
cancellationToken System.Threading.CancellationToken Token which can be used to cancel the task.
Name Description
System.Threading.Tasks.TaskCanceledException The task is cancelled for specified time.

Trimble.ID

Common interface for claimset providers

Retrieves a validate claimset from a given JSON web token

A Task that resolves to the claimset completion

This method has no parameters.

Trimble.ID

Common interface for endpoint providers

Retrieves a URL for the Trimble Identity authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

RetrieveDeviceAuthorizationEndpoint() method

Section titled “RetrieveDeviceAuthorizationEndpoint() method”

Retrieves a URL for the Trimble Identity device authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity end session endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity JSON web keyset endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity token endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity token revocation endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity user information endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Trimble.ID

Common interface for all HTTP client providers

The ClientId for the calling application

Retrieves a preconfigured HttpClient to access a given API

A Task that resolves to the value of the preconfigured HttpClient on completion

This method has no parameters.

Sets an additional and optional HttpMessageHandler.

Name Type Description
handler System.Net.Http.HttpMessageHandler The handler.

Trimble.ID

Common interface for all key set providers

Returns a Task that resolves to a key set

This method has no parameters.

Trimble.ID

Interface for persistant storage

Retrieve a named value from persistant storage

This method has no parameters.

Remove a named value from persistant storage

This method has no parameters.

Store a named value in persistant storage

This method has no parameters.

Trimble.ID

Interface implemented by all token providers

Retrieves an access token for the authenticated application or user

A Task that resolves to the value of the access token on completion

This method has no parameters.

RetrieveTokenAsync(cancellationToken) method

Section titled “RetrieveTokenAsync(cancellationToken) method”

Retrieves an access token asynchronously for the authenticated application or user

An AccessToken which can be used to authenticate service client calls.

Name Type Description
cancellationToken System.Threading.CancellationToken A CancellationToken controlling the request lifetime.

Trimble.ID

Wrapper for IPersistantStorage that adds encryption functionality

Constructor

This constructor has no parameters.

Retrieve a named value from persistant storage

This method has no parameters.

Remove a named value from persistant storage

This method has no parameters.

Store a named value in persistant storage

This method has no parameters.

Trimble.ID

Represents a logging handler for HTTP requests and responses.

Initializes a new instance of the LoggingHandler class.

Name Type Description
logger TrimbleCloud.Common.Logging.ILogger The logger instance.

SendAsync(request,cancellationToken) method

Section titled “SendAsync(request,cancellationToken) method”

Sends an HTTP request and logs the request and response.

The HTTP response message.

Name Type Description
request System.Net.Http.HttpRequestMessage The HTTP request message.
cancellationToken System.Threading.CancellationToken The cancellation token.

Trimble.ID

A token provider based on the OAuth On Behalf grant type

const string CLIENT_ID = "APPLICATION_CLIENT_ID";
const string CLIENT_SECRET = "APPLICATION_CLIENT_SECRET";
var accessToken = "CALLERS_ACCESS_TOKEN";
const string TOKEN_ENDPOINT = "https://id.trimble.com/oauth/token";
IEndpointProvider endpointProvider = new FixedEndpointProvider(tokenEndpoint: new Uri(TOKEN_ENDPOINT, UriKind.Absolute));
ITokenProvider tokenProvider = new OnBehalfGrantTokenProvider(endpointProvider, CLIENT_ID, CLIENT_SECRET, accessToken);
var token = await tokenProvider.RetrieveToken();

Implements ITokenProvider

#ctor(endpointProvider,consumerKey,consumerSecret,accessToken,productName) constructor

Section titled “#ctor(endpointProvider,consumerKey,consumerSecret,accessToken,productName) constructor”

Public constructor for OnBehalfTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity token endpoints
consumerKey System.String The consumer key for the calling application
consumerSecret System.String The consumer secret for the calling application
accessToken System.String The access token for the authenticated user that this application wishes to act on behalf of when calling another API
productName System.String The product name of the consuming application (Optional).

Implements ITokenProvider

Retrieves an access token for the application

A Task that resolves to the value of the access token on completion

This method has no parameters.

Name Description
Trimble.ID.AuthorizationFailedException Thrown when a call to the token endpoint fails

Inherit from parent.

This method has no parameters.

Fluent extension for adding scopes

Name Type Description
scopes System.Collections.Generic.IEnumerable{System.String} The requested scopes

Trimble.ID

An endpoint provider that returns values from a OpenID well known configuration

const string PROD_CONFIGURATION_ENDPOINT = "https://id.trimble.com/.well-known/openid-configuration";
const string STAGE_CONFIGURATION_ENDPOINT = "https://stage.id.trimblecloud.com/.well-known/openid-configuration";
IEndpointProvider endpointProvider = new OpenIdEndpointProvider(new Uri(PROD_CONFIGURATION_ENDPOINT, UriKind.Absolute));
var authorizationEndpoint = await endpointProvider.RetrieveAuthorizationEndpoint();
var tokenEndpoint = await endpointProvider.RetrieveTokenEndpoint();

Implements IEndpointProvider

#ctor(configurationEndpoint,productName) constructor

Section titled “#ctor(configurationEndpoint,productName) constructor”

Public constructor for OpenIdEndpointProvider class

Name Type Description
configurationEndpoint System.Uri The URL for the Trimble Identity OpenID well know configuration endpoint
productName System.String The product name of the consuming application (optional).

#ctor(configurationEndpoint,tokenRevocationEndpoint) constructor

Section titled “#ctor(configurationEndpoint,tokenRevocationEndpoint) constructor”

Public constructor for OpenIdEndpointProvider class

Name Type Description
configurationEndpoint System.Uri The URL for the Trimble Identity OpenID well know configuration endpoint
tokenRevocationEndpoint System.Uri The URL for the Trimble Identity token revocation endpoint, if not supplied this is computed relative to the token endpoint

Retrieves a URL for the Trimble Identity authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Name Description
System.Exception Thrown if the configuration endpoint returns an error

RetrieveDeviceAuthorizationEndpoint() method

Section titled “RetrieveDeviceAuthorizationEndpoint() method”

Retrieves a URL for the Trimble Identity device authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Name Description
System.Exception Thrown if the configuration endpoint returns an error

Retrieves a URL for the Trimble Identity token revocation endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Retrieves a URL for the Trimble Identity authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Name Description
System.Exception Thrown if the configuration endpoint returns an error

Retrieves a URL for the Trimble Identity authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Name Description
System.Exception Thrown if the configuration endpoint returns an error

Retrieves a URL for the Trimble Identity authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Name Description
System.Exception Thrown if the configuration endpoint returns an error

Retrieves a URL for the Trimble Identity authorization endpoint

A Task that resolves to the value of the URL on completion

This method has no parameters.

Name Description
System.Exception Thrown if the configuration endpoint returns an error

Trimble.ID

A keyset provider based on the OAuth well known configuration

const string JWKS_ENDPOINT = "https://id.trimble.com/.well-known/jwks.json";
var endpointProvider = new FixedEndpointProvider(jwksEndpoint: new Uri(JWKS_ENDPOINT, UriKind.Absolute));
IKeySetProvider keysetProvider = new OpenIdKeySetProvider(endpointProvider);
var keyset = await keysetProvider.RetrieveKeySet();

Implements IKeysetProvider

#ctor(endpointProvider,productName) constructor

Section titled “#ctor(endpointProvider,productName) constructor”

Public constructor for OpenIdKeySetProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity JSON web keyset endpoint
productName System.String The product name of the consuming application (optional).

Implements IKeySetProvider

Retrieves an dictionary of named keys

A Task that resolves to a dictionary of named keys on completion

This method has no parameters.

Name Description
System.Exception Thrown when a JSON web keyset endpoint is not provided by the endpoint provider
System.Exception Thrown when a call to the JSON web keyset endpoint fails

Trimble.ID

Class to allow instansiation of RefreshableTokenProvider

#ctor(endpointProvider,consumerKey,productName) constructor

Section titled “#ctor(endpointProvider,consumerKey,productName) constructor”

Public constructor for RefreshableTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKey System.String The consumer key for the calling application
productName System.String The product name of the consuming application (optional).

Implements ITokenProvider

Trimble.ID

A token provider based on the OAuth refresh grant type

Implements ITokenProvider

#ctor(endpointProvider,consumerKey,productName) constructor

Section titled “#ctor(endpointProvider,consumerKey,productName) constructor”

Public constructor for RefreshableTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKey System.String The consumer key for the calling application
productName System.String The product name of the consuming application (optional).

Implements ITokenProvider

#ctor(endpointProvider,consumerKey,consumerSecret,accessToken,tokenExpiry,idToken,refreshToken) constructor

Section titled “#ctor(endpointProvider,consumerKey,consumerSecret,accessToken,tokenExpiry,idToken,refreshToken) constructor”

Public constructor for RefreshableTokenProvider class

Name Type Description
endpointProvider Trimble.ID.IEndpointProvider An endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKey System.String The consumer key for the calling application
consumerSecret System.String The consumer secret for the calling application
accessToken System.String The initial access token issued for the authenticated user
tokenExpiry System.DateTime The expiry time for the initial access token issued for the authenticated user
idToken System.String The ID token for the authenticated user
refreshToken System.String The refresh token for the authenticated user

Implements ITokenProvider

Checks online state.

True if online.

This method has no parameters.

This method has no parameters.

Static method to generate a code verifier

A code verifier string

This method has no parameters.

GetSilentTokenAsync(cancellationToken) method

Section titled “GetSilentTokenAsync(cancellationToken) method”

Get a token silently. Use CrossPlatLock to synchronize access to the cache only if the cache is stored in IsolatedFileStorage.

Name Type Description
cancellationToken System.Threading.CancellationToken

Retrieves a code verifier for the authenticated user for PKCE grant flow

A Task that resolves to the value of the code verifier on completion

This method has no parameters.

Name Description
System.Exception Thrown when a token endpoint is not provided by the endpoint provider
System.Exception Thrown when a call to the token endpoint fails

Retrieves an ID token for the authenticated user

A Task that resolves to the value of the ID token on completion

This method has no parameters.

Name Description
System.Exception Thrown when a token endpoint is not provided by the endpoint provider
System.Exception Thrown when a call to the token endpoint fails

Retrieves a refresh token for the authenticated user

A Task that resolves to the value of the refresh token on completion

This method has no parameters.

Name Description
System.Exception Thrown when a token endpoint is not provided by the endpoint provider
System.Exception Thrown when a call to the token endpoint fails

Retrieves an access token for the authenticated user

A Task that resolves to the value of the access token on completion

This method has no parameters.

Name Description
Trimble.ID.TokenRefreshException Thrown when a call to the token endpoint fails

Inherit from parent.

This method has no parameters.

Revokes a refresh token for the authenticated user

This method has no parameters.

WithAccessToken(accessToken,tokenExpiry) method

Section titled “WithAccessToken(accessToken,tokenExpiry) method”

Fluent method for RefreshableTokenProvider class

The current RefreshableTokenProvider

Name Type Description
accessToken System.String The initial access token issued for the authenticated user
tokenExpiry System.DateTime The expiry time for the initial access token issued for the authenticated user

Fluent method for RefreshableTokenProvider class

The current RefreshableTokenProvider

Name Type Description
clientSecret System.String The client secret for the calling application

Fluent method for RefreshableTokenProvider class

The current RefreshableTokenProvider

Name Type Description
idToken System.String The ID token for the authenticated user

Fluent method for enabling offline access

The current RefreshableTokenProvider

This method has no parameters.

WithPersistentStorage(persistentStorage) method

Section titled “WithPersistentStorage(persistentStorage) method”

Fluent method for RefreshableTokenProvider class

The current RefreshableTokenProvider

Name Type Description
persistentStorage Trimble.ID.IPersistantStorage The persistent storage for the refresh token

WithProofKeyForCodeExchange(codeVerifier) method

Section titled “WithProofKeyForCodeExchange(codeVerifier) method”

Fluent extension for Authorization Code with PKCE

Name Type Description
codeVerifier System.String The PKCE code verifier for the calling application

Fluent method for RefreshableTokenProvider class

The current RefreshableTokenProvider

Name Type Description
refreshToken System.String The refresh token for the authenticated user

WithRetryConfiguration(maxRetries,retryDelayInSeconds) method

Section titled “WithRetryConfiguration(maxRetries,retryDelayInSeconds) method”

Fluent method to configure retry behavior

The current RefreshableTokenProvider

Name Type Description
maxRetries System.Int32 Maximum number of retries
retryDelayInSeconds System.Int32 Base delay between retries in seconds

Generate a code challenge for the current code verifier

The calculated code challenge

This method has no parameters.

Trimble.ID.Utilities

ExecuteWithRetryAsync``1(func,shouldRetryPredicate,maxRetries,retryDelay,cancellationToken) method

Section titled “ExecuteWithRetryAsync``1(func,shouldRetryPredicate,maxRetries,retryDelay,cancellationToken) method”

Executes the provided function with retry logic.

The result of the function execution.

Name Type Description
func System.Func{System.Threading.Tasks.Task{``0}} The function to execute.
shouldRetryPredicate System.Func{System.Exception,System.Net.Http.HttpResponseMessage,System.Boolean} Function to determine if retry should be attempted based on the exception.
maxRetries System.Int32 Maximum number of retry attempts.
retryDelay System.Nullable{System.TimeSpan} Base delay between retries (will be multiplied by retry count for backoff).
cancellationToken System.Threading.CancellationToken Cancellation token.
Name Description
T The return type of the function.

ShouldRetryOnServerError(ex,response) method

Section titled “ShouldRetryOnServerError(ex,response) method”

Determines if the request should be retried based on the HTTP status code.

True if the request should be retried, otherwise false.

Name Type Description
ex System.Exception The exception that was thrown.
response System.Net.Http.HttpResponseMessage The HTTP response.

Trimble.ID

Represents a handler for adding authentication token to the request headers.

Initializes a new instance of the TokenHandler class.

Name Type Description
tokenProvider Trimble.ID.ITokenProvider The token provider used to retrieve the authentication token.

Represents a handler that adds an authentication token to the request headers before sending the request.

SendAsync(request,cancellationToken) method

Section titled “SendAsync(request,cancellationToken) method”

Sends the HTTP request with the added authentication token in the request headers.

The HTTP response message.

Name Type Description
request System.Net.Http.HttpRequestMessage The HTTP request message.
cancellationToken System.Threading.CancellationToken The cancellation token.

Trimble.ID

An exception class raised when a token refresh fails.

Creates a new TokenRefreshException with the specified message.

Name Type Description
message System.String

Creates a new TokenRefreshException with the specified message.

Name Type Description
message System.String The message describing the token refresh failure.
innerException System.Exception The exception underlying the token refresh failure.

Represents the event arguments for token refreshed event.

Initializes a new instance of the TokenRefreshedEventArgs class.

Name Type Description
accessToken System.String The access token.
expiresIn System.Int64 The access token expiration time

Gets the access token.

Trimble.ID

Represents the options for token validation.

Gets or sets the clock skew for validating tokens.

Name Description
System.ArgumentOutOfRangeException If ‘value’ is less than 0.

Trimble.ID

User information

The user’s email address

The user’s email address verification status

The user’s family name

The user’s given name

The user’s unique identifier

A URL to the user’s profile picture

Trimble.ID

A claimset provider that returns a validated claimset

var idToken = "USERS_ID_TOKEN";
const string JWKS_ENDPOINT = "https://identity.trimble.com/openid-certs";
IEndpointProvider endpointProvider = new FixedEndpointProvider(jwksEndpoint: new Uri(JWKS_ENDPOINT, UriKind.Absolute));
IKeysetProvider keysetProvider = new OpenIdKeySetProvider(endpointProvider);
IClaimsetProvider claimsetProvider = new ValidatedClaimsetProvider(keysetProvider);
var claimset = await RetrieveClaimset(idToken);
var userId = claimset["sub"];

Implements IKeysetProvider

#ctor(keysetProvider,productName) constructor

Section titled “#ctor(keysetProvider,productName) constructor”

Public constructor for ValidatedClaimsetProvider class

Name Type Description
keysetProvider Trimble.ID.IKeySetProvider A provider for the keyset used to validate the JWT claimeset
productName System.String The product name of the consuming application (optional).

Implements IClaimsetProvider

Retrieves a validate claimset from a given JSON web token

A Task that resolves to the claimset completion

This method has no parameters.

Name Description
System.Exception Thrown when the keyset provider does not provide the named key
System.Exception Thrown when the JSON web token is invalid

Fluent extension for setting token validation Options

Name Type Description
options Trimble.ID.TokenValidationOptions Contains a set of validation options when validating the token