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 angle brackets < >
.
Creating MindsphereCredentials Objects¶
Object Name: MindsphereCredentials
Creating MindsphereCredentials using a User Token¶
Applications can pass a user token which is obtained from the request header to clients using UserCredentials
object as below:
// Require the class UserCredentials available in mindsphere-sdk-node-core module
const UserCredentials = require('mindsphere-sdk-node-core').UserCredentials;
// Construct the UserCredentials object
let user_credentials = new UserCredentials({'authorization': '<user_token>'});
Creating MindsphereCredentials using App Specific Service Credentials¶
The app specific service credentials must be provided programmatically or via environment variables. App specific service credentials are obtained from Developer Cockpit or Operator Cockpit.
// Require the class AppCredentials available in `mindsphere-sdk-node-core` module
const AppCredentials = require('mindsphere-sdk-node-core').AppCredentials;
// Construct the AppCredentials object
let app_credentials = new AppCredentials({
keyStoreClientId: '<client_id>',
keyStoreClientSecret: '<client_secret>',
appName: '<app-name>',
appVersion: '<app_version>',
hostTenant: '<host_tenant>',
userTenant: '<user_tenant>'
});
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 MindSphere APIs with Service Credentials. If credentials are set via environment variables, the TenantCredentials
object does not need to be build.
// Require the class TenantCredentials available in mindsphere-sdk-node-core module
const TenantCredentials = require('mindsphere-sdk-node-core').TenantCredentials;
// Construct the TenantCredentials object
let tenant_credentials = new TenantCredentials({
clientId: '<client_id>',
clientSecret: '<client_secret>',
tenant:'<tenant_id>'
});
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. If credentials are set via environment variables, the TenantCredentials
object does not need to be build.
// Require the class TenantCredentials available in mindsphere-sdk-node-core module
const TenantCredentials = require('mindsphere-sdk-node-core').TenantCredentials;
// Construct the TenantCredentials object
let tenant_credentials = new TenantCredentials({
clientId: '<client_id>',
clientSecret: '<client_secret>',
tenant:'<tenant_id>',
subTenant:'<subtenant_id>'
});