Skip to content

Trimble.ID.Desktop

Trimble.ID.Desktop

Contents

Browser type

Namespace

Trimble.ID.Desktop

Summary

Provides methods to launch a URL in the default browser.

Launch() method

Summary

Launches the default browser with the specified URL.

Parameters

This method has no parameters.

BrowserPreferences type

Namespace

Trimble.ID.Desktop

Summary

Preferences for browser window

Height property

NewWindow property

Width property

X property

Y property

LocalhostAuthenticator type

Namespace

Trimble.ID.Desktop

Summary

An authenticator that utilizes a localhost callback

Example
const string CONFIGURATION_ENDPOINT = "https://id.trimble.com/.well-known/openid-configuration";
const string CLIENT_ID = "APPLICATION_CLIENT_ID";
var string SCOPES = new [] { "CSharpSDKTesting" };
IEndpointProvider endpointProvider = new OpenIdEndpointProvider(new Uri(CONFIGURATION_URL, UriKind.Absolute));
IAuthenticator authenticator = new LocalhostAuthenticator(endpointProvider, CLIENT_ID, SCOPES);
if (await authenticator.Login())
{
var userInfo = await authenticator.GetUserInfo();
var token = await authenticator.TokenProvider.RetrieveToken();
}
await authenticator.Logout(singleSignOut: true);
authenticator.Dispose();
Remarks

Implements IAuthenticator

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

Summary

Public constructor for LocalhostAuthenticator class

Parameters
NameTypeDescription
endpointProviderTrimble.ID.IEndpointProviderAn endpoint provider that provides the URL for the Trimble Identity authorization and token endpoints
consumerKeySystem.StringThe consumer key for the calling application
scopesSystem.String[]The scopes used in the authorization request, openid is specified by default
productNameSystem.StringThe product name of the consuming application (optional).

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

Dispose() method

Summary

Finalizer for the authenticator

Parameters

This method has no parameters.

Dispose() method

Summary

Dispose the authenticator

Parameters

This method has no parameters.

GetUserInfo() method

Summary

Validates the ID token and returns user claims

Returns

User claims from the ID token

Parameters

This method has no parameters.

LoadCachedLogin() method

Summary

Initialize the authenticator with a stored refresh token

Returns

true if the authenticator was initialzed with an existing refresh 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.CancellationTokenThe optional cancellation token.
Exceptions
NameDescription
System.TimeoutExceptionLogin operation has timed out after waiting for specified time.
System.Threading.Tasks.TaskCanceledExceptionTask is canceled when cancellation token is requested and the operation might takes longer time to respond
Remarks

Only one login or logout operation is permitted at a time, all previously started operations will return false

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.CancellationTokenThe optional cancellation token.
Exceptions
NameDescription
System.Threading.Tasks.TaskCanceledExceptionTask is canceled when cancellation token is requested and the operation might takes longer time to respond
Remarks

Only one login or logout operation is permitted at a time, all previously started operations will return false

WithBrowserPreferences(preferences) method

Summary

Fluent method to specify browser preferences

Parameters
NameTypeDescription
preferencesTrimble.ID.Desktop.BrowserPreferencesThe browser preferences

WithFixedPort(port) method

Summary

Fluent method to specify an alternative port

Parameters
NameTypeDescription
portSystem.Int32The alternative port to use for the localhost listener

WithLoopbackAddress(address) method

Summary

Fluent method to specify an alternative host

Parameters
NameTypeDescription
addressSystem.StringThe alternative host to use for the localhost listener

WithOfflineAccess() method

Summary

Fluent method to enable offline access.

Returns

The authenticator configured for offline access.

Parameters

This method has no parameters.

Remarks

This allows the application to access user’s data and token even when offline. Note that even in offline mode, at least one initial sign-in is required to initialize the token from the cache.

WithPersistentStorage(persistentStorage) method

Summary

Fluent method to specify persistent storage option.

Parameters
NameTypeDescription
persistentStorageTrimble.ID.IPersistantStorageThe persistent storage for refresh tokens

LocalhostListener type

Namespace

Trimble.ID.Desktop

Summary

A class that listens for HTTP requests on the localhost.

#ctor(address) constructor

Summary

Constructor for localhost listener

Parameters
NameTypeDescription
addressSystem.StringThe host address to listen on, default 127.0.0.1

ANY_PORT constants

LOOPBACK_ADDRESS constants

Address property

Port property

Dispose() method

Summary

Dispose method for LocalhostListener class

Parameters

This method has no parameters.

Dispose(disposing) method

Summary

Frees the resources used by the LocalhostListener object.

Parameters
NameTypeDescription
disposingSystem.BooleanA boolean value indicating whether the method is being called

Start(port) method

Summary

Start a listener on the specified port

Returns

true on success

Parameters
NameTypeDescription
portSystem.Int32The port to start the listener on, or ANY_PORT

TokenProviderWrapper type

Namespace

Trimble.ID.Desktop.LocalhostAuthenticator

RetrieveToken() method

Summary

Retrieves the access token.

Returns

The access token.

Parameters

This method has no parameters.

Exceptions
NameDescription
System.InvalidOperationExceptionThrown when the user is not logged in.
Trimble.ID.TokenRefreshExceptionThrown when the token failed to refresh.

RetrieveTokenAsync(cancellationToken) method

Summary

Retrieves the access token.

Returns

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

Parameters
NameTypeDescription
cancellationTokenSystem.Threading.CancellationTokenA CancellationToken controlling the request lifetime.
Exceptions
NameDescription
System.InvalidOperationExceptionThrown when the user is not logged in.
Trimble.ID.TokenRefreshExceptionThrown when the token failed to refresh.