Skip to content

Token Management Client for Java

Introduction

The Token Management client is used to retrieve tokens, which allow applications to access IoT data on customer tenants to whom the application has been provisioned.

Refer to Token Management Service for more information about the service.

Info

The Token Management Service is currently only available in region Europe 1.

Token Management Operations

Client Name: TokenManagerClient

Token Expiry

Tokens are valid for 30 minutes. Cache and reuse tokens until expiry.

Get Token using Environment Variables

This operation uses the Token Management Service to create a token. All parameters are automatically fetched from the following environment variables:

Environment Variable Description
MDSP_OS_VM_APP_NAME The application name as stored by the version management of the Operator Services (OS_VM).
MDSP_OS_VM_APP_VERSION The application version as stored by the version management of the Operator Services (OS_VM).
MDSP_KEY_STORE_CLIENT_ID The client ID, which is part of the service credentials.
MDSP_KEY_STORE_CLIENT_SECRET The client secrete, which is part of the service credentials.

Note

On developer tenants the environment variables must be set manually in the Developer Cockpit. On operator tenants they are set automatically during application registration.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
//Create client object "tokenManagerClient"
TokenManagerClient tokenManagerClient = TokenManagerClient.builder()
                    .mindsphereCredentials(credentials)
                    .restClientConfig(config)
                    .build();

AccessTokenResponse accessTokenResponse = null;

try {
  accessTokenResponse = tokenManagerClient.getToken();
} catch (MindsphereException e) {
  // Exception handling
}

Get Token using Service Credentials

This operation uses the Token Management Service to create a token. The client ID and client secret are provided in the request. The application name and version are automatically fetched from environment variables as described above.

1
2
3
4
5
6
7
8
//Create client object "tokenManagerClient" as shown above
AccessTokenResponse accessTokenResponse = null;

try {
  accessTokenResponse = tokenManagerClient.getToken("clientId","clientSecret");
} catch (MindsphereException e) {
  // Exception handling
}

Get Token

This operation uses the Token Management Service to create a token. The application name and version, the client ID and the client secret are provided in the request.

1
2
3
4
5
6
7
8
//Create client object "tokenManagerClient" as shown above
AccessTokenResponse accessTokenResponse = null;

try {
  accessTokenResponse = tokenManagerClient.getToken("applicationName","applicationVersion","clientId","clientSecret",);
} catch (MindsphereException e) {
  // Exception handling
}

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.