Skip to content

Trimble.ID

Trimble.ID

Contents

AccessToken type

Namespace

Trimble.ID

Summary

Represents Trimble identity access token with expiry information.

#ctor(accessToken,expiresOn) constructor

Summary

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

Parameters
NameTypeDescription
accessTokenSystem.StringThe access token value.
expiresOnSystem.DateTimeOffsetThe access token expiry date.

ExpiresOn property

Summary

Gets the time when the provided token expires.

Token property

Summary

Get the access token value.

Equals() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

GetHashCode() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

AuthorizationCodeGrantTokenProvider type

Namespace

Trimble.ID

Summary

A token provider based on the OAuth Authorization Code grant type

Example
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();
Remarks

Implements ITokenProvider

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

Summary

Public constructor for AuthorizationCodeGrantTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity authorization and token endpoints
clientIdSystem.StringThe client Id for the calling application
redirectUrlSystem.StringThe URL to which Trimble Identity should redirect after successfully authenticating a user
productNameSystem.StringThe product name of the consuming application (Optional).

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

Summary

Public constructor for AuthorizationCodeGrantTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity authorization and token endpoints
clientIdSystem.StringThe client Id for the calling application
redirectUriSystem.UriThe URL to which Trimble Identity should redirect after successfully authenticating a user
productNameSystem.StringThe product name of the consuming application (Optional).
Remarks

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

State property

GetOAuthLogoutRedirect(state) method

Summary

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

Returns

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

Parameters
NameTypeDescription
stateSystem.StringAn optional state parameter that will be passed back to the caller via the redirect URL
Exceptions
NameDescription
System.InvalidOperationExceptionThrown when an ID token is not available

GetOAuthRedirect(state,prompt) method

Summary

Get a redirect URL for Trimble Identity

Returns

An awaitable Task that resolves to the redirect URL

Parameters
NameTypeDescription
stateSystem.StringAn optional state parameter that will be passed back to the caller via the redirect URL
promptSystem.BooleanThis parameter is optional and determines whether to display the login UI. The default value is True.
Exceptions
NameDescription
Trimble.ID.AuthorizationFailedExceptionThrown when an authorization endpoint is not provided by the endpoint provider

ValidateCode(code) method

Summary

Validate the code parameter passed to the application by Trimble Identity

Returns

True if the code is valid

Parameters
NameTypeDescription
codeSystem.StringThe code query string from the URL
Exceptions
NameDescription
Trimble.ID.AuthorizationFailedExceptionThrown when failed to validate the given auth code

ValidateQuery(query) method

Summary

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

Returns

True if the query string is valid

Parameters
NameTypeDescription
querySystem.StringThe query string from the URL
Exceptions
NameDescription
Trimble.ID.AuthorizationFailedExceptionThrown when failed to validate the given auth code

WithIdentityProvider(identityProvider) method

Summary

Add Identity Provider to the authorization URL

Parameters
NameTypeDescription
identityProviderSystem.StringAn optional parameter which specifies a federated identity provider that should be used to authenticate

WithLogoutRedirect(logoutRedirectUrl) method

Summary

Add Redirect URL to an AuthorizationCodeGrantTokenProvider

Parameters
NameTypeDescription
logoutRedirectUrlSystem.StringA URL which the browser will return to after logout
Remarks

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

WithLogoutRedirect(logoutRedirectUri) method

Summary

Add Redirect URL to an AuthorizationCodeGrantTokenProvider

Parameters
NameTypeDescription
logoutRedirectUriSystem.UriA URL which the browser will return to after logout
Remarks

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

WithScopes(scopes) method

Summary

Fluent extension for adding scopes

Parameters
NameTypeDescription
scopesSystem.Collections.Generic.IEnumerable{System.String}The requested scopes

AuthorizationFailedException type

Namespace

Trimble.ID

Summary

An exception class raised for errors in authorizing client requests.

#ctor(message) constructor

Summary

Creates a new AuthorizationFailedException with the specified message.

Parameters
NameTypeDescription
messageSystem.String

#ctor(message,innerException) constructor

Summary

Creates a new AuthorizationFailedException with the specified message.

Parameters
NameTypeDescription
messageSystem.StringThe message describing the authorization failure.
innerExceptionSystem.ExceptionThe exception underlying the authorization failure.

BearerTokenHttpClientProvider type

Namespace

Trimble.ID

Summary

A HttpClient provider for APIs using Bearer token authorization

Example
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();
Remarks

Implements IHttpClientProvider

#ctor(tokenProvider,baseAddress,productName) constructor

Summary

Public constructor for BearerTokenHttpClientProvider class

Parameters
NameTypeDescription
tokenProviderTrimble.ID.ITokenProviderA token provider that provides the access token for the authenticated application or user
baseAddressSystem.UriThe base address for the API that will be called
productNameSystem.StringThe product name of the consuming application (Optional).
Remarks

Implements IHttpClientProvider

ClientId property

Summary

Gets the client ID.

Logger property

Summary

Gets or sets the logger for this HTTP client provider

GetClientIdAsync() method

Summary

Gets the client ID asynchronously.

Parameters

This method has no parameters.

RetrieveClient() method

Summary

Retrieves a preconfigured HttpClient to access a given API

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown when a token is not provided by the token provider

SetHttpMessageHandler(handler) method

Summary

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

Parameters
NameTypeDescription
handlerSystem.Net.Http.HttpMessageHandlerThe HTTP message handler to be set.

ClientCredentialTokenProvider type

Namespace

Trimble.ID

Summary

A token provider based on the OAuth Client Credential grant type

Example
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();
Remarks

Implements ITokenProvider

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

Summary

Public constructor for ClientCredentialTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKeySystem.StringThe consumer key for the calling application
consumerSecretSystem.StringThe consumer secret for the calling application
productNameSystem.StringThe product name of the consuming application (Optional).
Remarks

Implements ITokenProvider

RetrieveToken() method

Summary

Retrieves an access token for the application

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
Trimble.ID.AuthorizationFailedExceptionThrown when a call to the token endpoint fails to obtain token

RetrieveTokenAsync() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

WithScopes(scopes) method

Summary

Fluent extension for adding scopes

Parameters
NameTypeDescription
scopesSystem.Collections.Generic.IEnumerable{System.String}The requested scopes

DeviceAuthorizationResponse type

Namespace

Trimble.ID

Summary

Represents the response of DeviceAuthorization.

DeviceCode property

Summary

Gets or sets the device code.

ExpiresIn property

Summary

Gets or sets the expiration time in seconds.

Interval property

Summary

Gets or sets the interval.

UserCode property

Summary

Gets or sets the user code.

VerificationUri property

Summary

Gets or sets the verification URI.

VerificationUriComplete property

Summary

Gets or sets the complete verification URI.

DeviceAuthorizationStatus type

Namespace

Trimble.ID

Summary

Represents the authorization status of a device.

ACCESS_DENIED constants

Summary

Access denied authorization status.

ACCESS_GRANTED constants

Summary

Access granted authorization status.

AUTHORIZATION_PENDING constants

Summary

Authorization pending authorization status.

CODE_EXPIRED constants

Summary

Code expired authorization status.

NONE constants

Summary

No authorization status.

SLOW_DOWN constants

Summary

Slow down authorization status.

DeviceAuthorizationTokenProvider type

Namespace

Trimble.ID

Summary

A token provider based on the Device Authorization grant type

Remarks

Implements ITokenProvider

#ctor(endpointProvider,clientId,productName) constructor

Summary

Public constructor for DeviceAuthorizationTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity token endpoint
clientIdSystem.StringThe consumer key for the calling application
productNameSystem.StringThe product name of the consuming application (Optional).

CreateAuthorization() method

Summary

Request authorization

Returns

DeviceAuthorizationResponse that contains user code, device code and verification uri

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown when a call to the device authorization endpoint fails

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

Summary

Performs token request

Parameters
NameTypeDescription
deviceCodeSystem.StringDevice code to perform token request
pollIntervalSystem.Int32Time interval between each request
timeoutSystem.Int32The maximum time until the request times out
onCallbackSystem.Action{Trimble.ID.DeviceAuthorizationStatus}Callback method to check whether the device has been authorized
cancellationTokenSystem.Threading.CancellationTokenCancellation token
Exceptions
NameDescription
System.TimeoutExceptionThrown when a token request times out
Trimble.ID.AuthorizationFailedExceptionThrown when a call to device authoiration fails

RetrieveIdToken() method

Summary

Retrieves a id token for the application

Returns

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

Parameters

This method has no parameters.

RetrieveRefreshToken() method

Summary

Retrieves a refresh token for the application

Returns

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

Parameters

This method has no parameters.

RetrieveToken() method

Summary

Retrieves an access token for the application

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
Trimble.ID.TokenRefreshExceptionThrown when a call to the token endpoint fails

RetrieveTokenAsync() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

WithClientSecret(clientSecret) method

Summary

Fluent extension for adding client secret

Parameters
NameTypeDescription
clientSecretSystem.StringThe client secret for the calling application

WithScopes(scopes) method

Summary

Fluent extension for adding scopes

Parameters
NameTypeDescription
scopesSystem.Collections.Generic.IEnumerable{System.String}The requested scopes

DeviceTokenErrorResponse type

Namespace

Trimble.ID

Summary

Represents the device token error response.

Error property

Summary

Gets or sets the error message.

ErrorDescription property

Summary

Gets or sets the error description.

EncryptedStorage type

Namespace

Trimble.ID

Summary

Wrapper for IPersistantStorage that adds encryption functionality

#ctor() constructor

Summary

Constructor

Parameters

This constructor has no parameters.

CombineEntropy() method

Summary

Combines the secret with additional entropy

Parameters

This method has no parameters.

GetItem() method

Summary

Retrieve a named value from persistant storage

Parameters

This method has no parameters.

RemoveItem() method

Summary

Remove a named value from persistant storage

Parameters

This method has no parameters.

SetItem() method

Summary

Store a named value in persistant storage

Parameters

This method has no parameters.

ErrorMessage type

Namespace

Trimble.ID

Summary

The Authorization Error messages.

FailedToGetToken constants

Summary

The error message.

FailedToRefreshToken constants

Summary

The error message.

FailedToReturnOAuthRedirect constants

Summary

The error message.

FailedToValidateOAuthCode constants

Summary

The error message.

IdTokenIsRequired constants

Summary

The error message.

NoKeysetEndpointProvider constants

Summary

The error message.

RefreshTokenIsNullOrEmpty constants

Summary

Error message for when refresh token is null or empty

TokenRefreshFailed constants

Summary

Error message for failed token refresh

FixedEndpointProvider type

Namespace

Trimble.ID

Summary

An endpoint provider that returns fixed values

Example
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();
Remarks

Implements IEndpointProvider

#ctor(productName) constructor

Summary

Public constructor for FixedEndpointProvider class

Parameters
NameTypeDescription
productNameSystem.StringThe product name of the consuming application (Optional).

#ctor() constructor

Summary

Protected copy constructor for FixedEndpointProvider class

Parameters

This constructor has no parameters.

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

Summary

Public constructor for FixedEndpointProvider class

Parameters
NameTypeDescription
authorizationEndpointSystem.UriThe URL for the Trimble Identity authorization endpoint
tokenEndpointSystem.UriThe URL for the Trimble Identity token endpoint
userInfoEndpointSystem.UriThe URL for the Trimble Identity user information endpoint
tokenRevocationEndpointSystem.UriThe URL for the Trimble Identity token revocation endpoint, if not supplied this is computed relative to the token endpoint
jwksEndpointSystem.UriThe URL for the Trimble Identity JSON web keyset endpoint
endSessionEndpointSystem.UriThe URL for the Trimble Identity end session endpoint, if not supplied this is computed relative to the token endpoint
deviceAuthorizationEndpointSystem.UriThe URL for the Trimble Identity device authorization endpoint
Remarks

Implements IEndpointProvider

RetrieveAuthorizationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity authorization endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveDeviceAuthorizationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity device authorization endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveEndSessionEndpoint() method

Summary

Retrieves a URL for the Trimble Identity token revocation endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveJSONWebKeySetEndpoint() method

Summary

Retrieves a URL for the Trimble Identity JSON web keyset endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveTokenEndpoint() method

Summary

Retrieves a URL for the Trimble Identity token endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveTokenRevocationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity token revocation endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveUserInfoEndpoint() method

Summary

Retrieves a URL for the Trimble Identity user information endpoint

Returns

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

Parameters

This method has no parameters.

WithAuthorizationEndpoint(authorizationEndpoint) method

Summary

Add an authorization endpoint

Returns

A new instance of a FixedEndpointProvider

Parameters
NameTypeDescription
authorizationEndpointSystem.UriThe URL for the Trimble Identity authorization endpoint

WithDeviceAuthorizationEndpoint(deviceAuthorizationEndpoint) method

Returns

A new instance of a FixedEndpointProvider

Parameters
NameTypeDescription
deviceAuthorizationEndpointSystem.UriThe URL for the Trimble Identity device authorization endpoint

WithEndSessionEndpoint(endSessionEndpoint) method

Summary

Add an end session endpoint

Returns

A new instance of a FixedEndpointProvider

Parameters
NameTypeDescription
endSessionEndpointSystem.UriThe URL for the Trimble Identity end session endpoint, if not supplied this is computed relative to the token endpoint

WithJWKSEndpoint(jwksEndpoint) method

Summary

Add a JWKS endpoint

Returns

A new instance of a FixedEndpointProvider

Parameters
NameTypeDescription
jwksEndpointSystem.UriThe URL for the Trimble Identity JSON web keyset endpoint

WithTokenEndpoint(tokenEndpoint) method

Summary

Add a token endpoint

Returns

A new instance of a FixedEndpointProvider

Parameters
NameTypeDescription
tokenEndpointSystem.UriThe URL for the Trimble Identity token endpoint

WithTokenRevocationEndpoint(tokenRevocationEndpoint) method

Summary

Add a token revocation endpoint

Returns

A new instance of a FixedEndpointProvider

Parameters
NameTypeDescription
tokenRevocationEndpointSystem.UriThe URL for the Trimble Identity token revocation endpoint, if not supplied this is computed relative to the token endpoint

WithUserInfoEndpoint(userInfoEndpoint) method

Summary

Add a user info endpoint

Returns

A new instance of a FixedEndpointProvider

Parameters
NameTypeDescription
userInfoEndpointSystem.UriThe URL for the Trimble Identity user information endpoint

FixedKeySetProvider type

Namespace

Trimble.ID

Summary

A keyset provider that returns a fixed keyset

Example
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();
Remarks

Implements IKeysetProvider

#ctor(keyset) constructor

Summary

Public constructor for FixedKeySetProvider class

Parameters
NameTypeDescription
keysetSystem.Collections.Generic.Dictionary{System.String,System.Security.Cryptography.RSACryptoServiceProvider}A dictionary of named keys
Remarks

Implements IKeySetProvider

RetrieveKeySet() method

Summary

Retrieves an dictionary of named keys

Returns

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

Parameters

This method has no parameters.

FixedTokenProvider type

Namespace

Trimble.ID

Summary

A token provider that returns a fixed token

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

Implements ITokenProvider

#ctor(token,productName) constructor

Summary

Public constructor for FixedTokenProvider class

Parameters
NameTypeDescription
tokenSystem.StringThe fixed token to return
productNameSystem.StringThe product name of the consuming application (Optional).
Remarks

Implements ITokenProvider

#ctor(token,expiresIn,productName) constructor

Summary

Public constructor for FixedTokenProvider class

Parameters
NameTypeDescription
tokenSystem.StringThe fixed token to return
expiresInSystem.Int32The expiration time of the token in seconds
productNameSystem.StringThe product name of the consuming application (Optional).
Remarks

Implements ITokenProvider

RetrieveToken() method

Summary

Retrieves an access token for the user or application

Returns

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

Parameters

This method has no parameters.

RetrieveTokenAsync() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

IAuthenticator type

Namespace

Trimble.ID

Summary

Common interface for authenticators

IsLoggedIn property

Summary

Get the logged in state

LegacyTokenProvider property

Summary

Get the token provider for this authenticator

Remarks

This token provider can be used with other SDK components

TokenProvider property

Summary

Get the token provider for this authenticator

Remarks

This token provider can be used with other SDK components

GetUserInfo() method

Summary

Validates the ID token and returns user claims

Returns

User claims from the ID token

Parameters

This method has no parameters.

Login(silent,timeoutInMs,cancellationToken) method

Summary

Log the user in

Returns

true if the user was successfully logged in

Parameters
NameTypeDescription
silentSystem.Booleantrue if no UI should be shown i.e. prompt=none
timeoutInMsSystem.Int32Specify the length of time that client waits for a login response when making a login attempt. The default timeout value is 3 minutes.
cancellationTokenSystem.Threading.CancellationTokenToken which can be used to cancel the task.
Exceptions
NameDescription
System.TimeoutExceptionLogin operation has timed out after waiting for specified time.
System.Threading.Tasks.TaskCanceledExceptionThe task is cancelled for specified time.

Logout(singleSignOut,cancellationToken) method

Summary

Log the user out

Returns

true if the user was successfully logged out

Parameters
NameTypeDescription
singleSignOutSystem.Booleantrue if the single sign in session should be terminated
cancellationTokenSystem.Threading.CancellationTokenToken which can be used to cancel the task.
Exceptions
NameDescription
System.Threading.Tasks.TaskCanceledExceptionThe task is cancelled for specified time.

IClaimsetProvider type

Namespace

Trimble.ID

Summary

Common interface for claimset providers

RetrieveClaimset() method

Summary

Retrieves a validate claimset from a given JSON web token

Returns

A Task that resolves to the claimset completion

Parameters

This method has no parameters.

IEndpointProvider type

Namespace

Trimble.ID

Summary

Common interface for endpoint providers

RetrieveAuthorizationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity authorization endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveDeviceAuthorizationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity device authorization endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveEndSessionEndpoint() method

Summary

Retrieves a URL for the Trimble Identity end session endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveJSONWebKeySetEndpoint() method

Summary

Retrieves a URL for the Trimble Identity JSON web keyset endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveTokenEndpoint() method

Summary

Retrieves a URL for the Trimble Identity token endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveTokenRevocationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity token revocation endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveUserInfoEndpoint() method

Summary

Retrieves a URL for the Trimble Identity user information endpoint

Returns

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

Parameters

This method has no parameters.

IHttpClientProvider type

Namespace

Trimble.ID

Summary

Common interface for all HTTP client providers

ClientId property

Summary

The ClientId for the calling application

RetrieveClient() method

Summary

Retrieves a preconfigured HttpClient to access a given API

Returns

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

Parameters

This method has no parameters.

SetHttpMessageHandler(handler) method

Summary

Sets an additional and optional HttpMessageHandler.

Parameters
NameTypeDescription
handlerSystem.Net.Http.HttpMessageHandlerThe handler.

IKeySetProvider type

Namespace

Trimble.ID

Summary

Common interface for all key set providers

RetrieveKeySet() method

Summary

Returns a Task that resolves to a key set

Parameters

This method has no parameters.

IPersistantStorage type

Namespace

Trimble.ID

Summary

Interface for persistant storage

GetItem() method

Summary

Retrieve a named value from persistant storage

Parameters

This method has no parameters.

RemoveItem() method

Summary

Remove a named value from persistant storage

Parameters

This method has no parameters.

SetItem() method

Summary

Store a named value in persistant storage

Parameters

This method has no parameters.

ITokenProvider type

Namespace

Trimble.ID

Summary

Interface implemented by all token providers

RetrieveToken() method

Summary

Retrieves an access token for the authenticated application or user

Returns

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

Parameters

This method has no parameters.

RetrieveTokenAsync(cancellationToken) method

Summary

Retrieves an access token asynchronously for the authenticated application or user

Returns

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

Parameters
NameTypeDescription
cancellationTokenSystem.Threading.CancellationTokenA CancellationToken controlling the request lifetime.

IsolatedFileStorage type

Namespace

Trimble.ID

Summary

Wrapper for IPersistantStorage that adds encryption functionality

#ctor() constructor

Summary

Constructor

Parameters

This constructor has no parameters.

GetItem() method

Summary

Retrieve a named value from persistant storage

Parameters

This method has no parameters.

RemoveItem() method

Summary

Remove a named value from persistant storage

Parameters

This method has no parameters.

SetItem() method

Summary

Store a named value in persistant storage

Parameters

This method has no parameters.

LoggingHandler type

Namespace

Trimble.ID

Summary

Represents a logging handler for HTTP requests and responses.

#ctor(logger) constructor

Summary

Initializes a new instance of the LoggingHandler class.

Parameters
NameTypeDescription
loggerTrimbleCloud.Common.Logging.ILoggerThe logger instance.

SendAsync(request,cancellationToken) method

Summary

Sends an HTTP request and logs the request and response.

Returns

The HTTP response message.

Parameters
NameTypeDescription
requestSystem.Net.Http.HttpRequestMessageThe HTTP request message.
cancellationTokenSystem.Threading.CancellationTokenThe cancellation token.

OnBehalfGrantTokenProvider type

Namespace

Trimble.ID

Summary

A token provider based on the OAuth On Behalf grant type

Example
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();
Remarks

Implements ITokenProvider

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

Summary

Public constructor for OnBehalfTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity token endpoints
consumerKeySystem.StringThe consumer key for the calling application
consumerSecretSystem.StringThe consumer secret for the calling application
accessTokenSystem.StringThe access token for the authenticated user that this application wishes to act on behalf of when calling another API
productNameSystem.StringThe product name of the consuming application (Optional).
Remarks

Implements ITokenProvider

RetrieveToken() method

Summary

Retrieves an access token for the application

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
Trimble.ID.AuthorizationFailedExceptionThrown when a call to the token endpoint fails

RetrieveTokenAsync() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

WithScopes(scopes) method

Summary

Fluent extension for adding scopes

Parameters
NameTypeDescription
scopesSystem.Collections.Generic.IEnumerable{System.String}The requested scopes

OpenIdEndpointProvider type

Namespace

Trimble.ID

Summary

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

Example
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();
Remarks

Implements IEndpointProvider

#ctor(configurationEndpoint,productName) constructor

Summary

Public constructor for OpenIdEndpointProvider class

Parameters
NameTypeDescription
configurationEndpointSystem.UriThe URL for the Trimble Identity OpenID well know configuration endpoint
productNameSystem.StringThe product name of the consuming application (optional).

#ctor(configurationEndpoint,tokenRevocationEndpoint) constructor

Summary

Public constructor for OpenIdEndpointProvider class

Parameters
NameTypeDescription
configurationEndpointSystem.UriThe URL for the Trimble Identity OpenID well know configuration endpoint
tokenRevocationEndpointSystem.UriThe URL for the Trimble Identity token revocation endpoint, if not supplied this is computed relative to the token endpoint

Production property

Staging property

RetrieveAuthorizationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity authorization endpoint

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown if the configuration endpoint returns an error

RetrieveDeviceAuthorizationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity device authorization endpoint

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown if the configuration endpoint returns an error

RetrieveEndSessionEndpoint() method

Summary

Retrieves a URL for the Trimble Identity token revocation endpoint

Returns

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

Parameters

This method has no parameters.

RetrieveJSONWebKeySetEndpoint() method

Summary

Retrieves a URL for the Trimble Identity authorization endpoint

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown if the configuration endpoint returns an error

RetrieveTokenEndpoint() method

Summary

Retrieves a URL for the Trimble Identity authorization endpoint

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown if the configuration endpoint returns an error

RetrieveTokenRevocationEndpoint() method

Summary

Retrieves a URL for the Trimble Identity authorization endpoint

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown if the configuration endpoint returns an error

RetrieveUserInfoEndpoint() method

Summary

Retrieves a URL for the Trimble Identity authorization endpoint

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown if the configuration endpoint returns an error

OpenIdKeySetProvider type

Namespace

Trimble.ID

Summary

A keyset provider based on the OAuth well known configuration

Example
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();
Remarks

Implements IKeysetProvider

#ctor(endpointProvider,productName) constructor

Summary

Public constructor for OpenIdKeySetProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity JSON web keyset endpoint
productNameSystem.StringThe product name of the consuming application (optional).
Remarks

Implements IKeySetProvider

RetrieveKeySet() method

Summary

Retrieves an dictionary of named keys

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown when a JSON web keyset endpoint is not provided by the endpoint provider
System.ExceptionThrown when a call to the JSON web keyset endpoint fails

RefreshableTokenProvider type

Namespace

Trimble.ID

Summary

Class to allow instansiation of RefreshableTokenProvider

#ctor(endpointProvider,consumerKey,productName) constructor

Summary

Public constructor for RefreshableTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKeySystem.StringThe consumer key for the calling application
productNameSystem.StringThe product name of the consuming application (optional).
Remarks

Implements ITokenProvider

RefreshableTokenProvider`1 type

Namespace

Trimble.ID

Summary

A token provider based on the OAuth refresh grant type

Remarks

Implements ITokenProvider

#ctor(endpointProvider,consumerKey,productName) constructor

Summary

Public constructor for RefreshableTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKeySystem.StringThe consumer key for the calling application
productNameSystem.StringThe product name of the consuming application (optional).
Remarks

Implements ITokenProvider

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

Summary

Public constructor for RefreshableTokenProvider class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity token endpoint
consumerKeySystem.StringThe consumer key for the calling application
consumerSecretSystem.StringThe consumer secret for the calling application
accessTokenSystem.StringThe initial access token issued for the authenticated user
tokenExpirySystem.DateTimeThe expiry time for the initial access token issued for the authenticated user
idTokenSystem.StringThe ID token for the authenticated user
refreshTokenSystem.StringThe refresh token for the authenticated user
Remarks

Implements ITokenProvider

_clientId constants

_clientSecret constants

_endpointProvider constants

_gaParameters constants

_messageHandler constants

CheckIsOnline() method

Summary

Checks online state.

Returns

True if online.

Parameters

This method has no parameters.

ConvertToUrlSafeBase64String() method

Parameters

This method has no parameters.

GenerateCodeVerifier() method

Summary

Static method to generate a code verifier

Returns

A code verifier string

Parameters

This method has no parameters.

GetSilentTokenAsync(cancellationToken) method

Summary

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

Returns
Parameters
NameTypeDescription
cancellationTokenSystem.Threading.CancellationToken

RetrieveCodeVerifier() method

Summary

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

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown when a token endpoint is not provided by the endpoint provider
System.ExceptionThrown when a call to the token endpoint fails

RetrieveIdToken() method

Summary

Retrieves an ID token for the authenticated user

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown when a token endpoint is not provided by the endpoint provider
System.ExceptionThrown when a call to the token endpoint fails

RetrieveRefreshToken() method

Summary

Retrieves a refresh token for the authenticated user

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown when a token endpoint is not provided by the endpoint provider
System.ExceptionThrown when a call to the token endpoint fails

RetrieveToken() method

Summary

Retrieves an access token for the authenticated user

Returns

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

Parameters

This method has no parameters.

Exceptions
NameDescription
Trimble.ID.TokenRefreshExceptionThrown when a call to the token endpoint fails

RetrieveTokenAsync() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

RevokeRefreshToken() method

Summary

Revokes a refresh token for the authenticated user

Parameters

This method has no parameters.

WithAccessToken(accessToken,tokenExpiry) method

Summary

Fluent method for RefreshableTokenProvider class

Returns

The current RefreshableTokenProvider

Parameters
NameTypeDescription
accessTokenSystem.StringThe initial access token issued for the authenticated user
tokenExpirySystem.DateTimeThe expiry time for the initial access token issued for the authenticated user

WithConsumerSecret(clientSecret) method

Summary

Fluent method for RefreshableTokenProvider class

Returns

The current RefreshableTokenProvider

Parameters
NameTypeDescription
clientSecretSystem.StringThe client secret for the calling application

WithIdToken(idToken) method

Summary

Fluent method for RefreshableTokenProvider class

Returns

The current RefreshableTokenProvider

Parameters
NameTypeDescription
idTokenSystem.StringThe ID token for the authenticated user

WithOfflineAccess() method

Summary

Fluent method for enabling offline access

Returns

The current RefreshableTokenProvider

Parameters

This method has no parameters.

WithPersistentStorage(persistentStorage) method

Summary

Fluent method for RefreshableTokenProvider class

Returns

The current RefreshableTokenProvider

Parameters
NameTypeDescription
persistentStorageTrimble.ID.IPersistantStorageThe persistent storage for the refresh token

WithProofKeyForCodeExchange(codeVerifier) method

Summary

Fluent extension for Authorization Code with PKCE

Parameters
NameTypeDescription
codeVerifierSystem.StringThe PKCE code verifier for the calling application

WithRefreshToken(refreshToken) method

Summary

Fluent method for RefreshableTokenProvider class

Returns

The current RefreshableTokenProvider

Parameters
NameTypeDescription
refreshTokenSystem.StringThe refresh token for the authenticated user

WithRetryConfiguration(maxRetries,retryDelayInSeconds) method

Summary

Fluent method to configure retry behavior

Returns

The current RefreshableTokenProvider

Parameters
NameTypeDescription
maxRetriesSystem.Int32Maximum number of retries
retryDelayInSecondsSystem.Int32Base delay between retries in seconds

_GenerateCodeChallenge() method

Summary

Generate a code challenge for the current code verifier

Returns

The calculated code challenge

Parameters

This method has no parameters.

RetryHandler type

Namespace

Trimble.ID.Utilities

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

Summary

Executes the provided function with retry logic.

Returns

The result of the function execution.

Parameters
NameTypeDescription
funcSystem.Func{System.Threading.Tasks.Task{“0}}The function to execute.
shouldRetryPredicateSystem.Func{System.Exception,System.Net.Http.HttpResponseMessage,System.Boolean}Function to determine if retry should be attempted based on the exception.
maxRetriesSystem.Int32Maximum number of retry attempts.
retryDelaySystem.Nullable{System.TimeSpan}Base delay between retries (will be multiplied by retry count for backoff).
cancellationTokenSystem.Threading.CancellationTokenCancellation token.
Generic Types
NameDescription
TThe return type of the function.

ShouldRetryOnServerError(ex,response) method

Summary

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

Returns

True if the request should be retried, otherwise false.

Parameters
NameTypeDescription
exSystem.ExceptionThe exception that was thrown.
responseSystem.Net.Http.HttpResponseMessageThe HTTP response.

TokenHandler type

Namespace

Trimble.ID

Summary

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

#ctor(tokenProvider) constructor

Summary

Initializes a new instance of the TokenHandler class.

Parameters
NameTypeDescription
tokenProviderTrimble.ID.ITokenProviderThe token provider used to retrieve the authentication token.

_tokenProvider constants

Summary

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

SendAsync(request,cancellationToken) method

Summary

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

Returns

The HTTP response message.

Parameters
NameTypeDescription
requestSystem.Net.Http.HttpRequestMessageThe HTTP request message.
cancellationTokenSystem.Threading.CancellationTokenThe cancellation token.

TokenRefreshException type

Namespace

Trimble.ID

Summary

An exception class raised when a token refresh fails.

#ctor(message) constructor

Summary

Creates a new TokenRefreshException with the specified message.

Parameters
NameTypeDescription
messageSystem.String

#ctor(message,innerException) constructor

Summary

Creates a new TokenRefreshException with the specified message.

Parameters
NameTypeDescription
messageSystem.StringThe message describing the token refresh failure.
innerExceptionSystem.ExceptionThe exception underlying the token refresh failure.

TokenRefreshedEventArgs type

Namespace
Summary

Represents the event arguments for token refreshed event.

#ctor(accessToken,expiresIn) constructor

Summary

Initializes a new instance of the TokenRefreshedEventArgs class.

Parameters
NameTypeDescription
accessTokenSystem.StringThe access token.
expiresInSystem.Int64The access token expiration time

AccessToken property

Summary

Gets the access token.

TokenValidationOptions type

Namespace

Trimble.ID

Summary

Represents the options for token validation.

ClockSkew property

Summary

Gets or sets the clock skew for validating tokens.

Exceptions
NameDescription
System.ArgumentOutOfRangeExceptionIf ‘value’ is less than 0.

UserInfo type

Namespace

Trimble.ID

Summary

User information

Email property

Summary

The user’s email address

EmailVerified property

Summary

The user’s email address verification status

FamilyName property

Summary

The user’s family name

GivenName property

Summary

The user’s given name

Id property

Summary

The user’s unique identifier

Picture property

Summary

A URL to the user’s profile picture

ValidatedClaimsetProvider type

Namespace

Trimble.ID

Summary

A claimset provider that returns a validated claimset

Example
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"];
Remarks

Implements IKeysetProvider

#ctor(keysetProvider,productName) constructor

Summary

Public constructor for ValidatedClaimsetProvider class

Parameters
NameTypeDescription
keysetProviderTrimble.ID.IKeySetProviderA provider for the keyset used to validate the JWT claimeset
productNameSystem.StringThe product name of the consuming application (optional).
Remarks

Implements IClaimsetProvider

RetrieveClaimset() method

Summary

Retrieves a validate claimset from a given JSON web token

Returns

A Task that resolves to the claimset completion

Parameters

This method has no parameters.

Exceptions
NameDescription
System.ExceptionThrown when the keyset provider does not provide the named key
System.ExceptionThrown when the JSON web token is invalid

WithOptions(options) method

Summary

Fluent extension for setting token validation Options

Returns
Parameters
NameTypeDescription
optionsTrimble.ID.TokenValidationOptionsContains a set of validation options when validating the token