Insights Hub Credentials¶
Introduction¶
The Insights Hub Credentials contain details for fetching new tokens and store fetched tokens.
Hint
Placeholders in the following samples are indicated by angular brackets < >
.
Creating MindsphereCredentials Objects¶
Object Name: MindsphereCredentials
Creating MindsphereCredentials using a User Token¶
MindsphereCredentials credentials = MindsphereCredentials.userTokenBuilder()
.authorization(<user_token>)
.build();
Deprecated Method
The following method for creating service credentials using a user token is deprecated and shall not be used anymore:
MindsphereCredentials credentials = MindsphereCredentials.builder()
.authorization(<user_token>)
.build();
Creating MindsphereCredentials using App Specific Service Credentials¶
The app specific service credentials are obtained from Developer Cockpit or Operator Cockpit. During the development of an application you may provide the service credentials programmatically. The final application should obtain the client ID, client secret, app name and app version from the environment variables and the host tenant and user tenant from the user token as shown below.
MindsphereCredentials credentials = MindsphereCredentials.appCredentialsBuilder()
.keyStoreClientId(<client_id>)
.keyStoreClientSecret(<client_secret>)
.appName(<app_name>)
.appVersion(<app_version>)
.hostTenant(<host_tenant>)
.userTenant(<user_tenant>)
.build();
MindsphereCredentials credentials = MindsphereCredentials.appCredentialsBuilder()
.authorization(<user_token>)
.build();
Note
The host tenant and user tenant values should not be hard-coded in the application as they are subject to change. MindSphereCredentials
objects can extract these values from the user token provided as authorization
parameter.
Creating MindsphereCredentials using Tenant Specific Service Credentials¶
The tenant specific service credentials must be provided programmatically or via environment variables. Tenant specific service credentials are obtained as described in Accessing Industrial IoT APIs with Service Credentials. If credentials are set via environment variables, the MindsphereCredentials
object does not need to be build.
MindsphereCredentials credentials = MindsphereCredentials.tenantCredentialsBuilder()
.clientId(<client_id>)
.clientSecret(<client_secret>)
.tenant(<tenant>)
.build();
Deprecated Method
The following method for creating tenant specific service credentials is deprecated and shall not be used anymore:
MindsphereCredentials credentials = MindsphereCredentials.builder()
.clientId(<client_id>)
.clientSecret(<client_secret>)
.tenant(<tenant_name>)
.build();
Creating MindsphereCredentials using Tenant specific Service Credentials for Subtenant Impersonation¶
The tenant specific service credentials for subtenant impersonation must be provided programmatically or via environment variables.
MindsphereCredentials credentials = MindsphereCredentials.tenantCredentialsBuilder()
.clientId(<client_id>)
.clientSecret(<client_secret>)
.tenant(<tenant>)
.subTenant(<subtenant>)
.tokenType(TokenScope.SUB_TENANT)
.build();