MindConnect-NodeJS - Setting up the CLI¶
The first step is to configure the CLI. For this, you will need application credentials (or deprecated service credentials) from your developer cockpit or SESSION and XSRF-TOKEN from the application you have been developing.
- Application Credentials - Recommended
- Service Credentials (deprecated)
- SESSION and XSRF-TOKEN cookie
Important: the service credentials (which are now deprecated) could only be acquired by emailing Insights Hub Support. They are not connected to the Cloud Foundry Service Credentials from Insights Hub settings app.
Application Credentials / Service Credentials Configuration¶
First start the credentials configuration. This will start a web server on your local computer where you can enter the credentials.
# run mc service-credentials --help for full information $ mc service-credentials navigate to http://localhost:4994 to configure the CLI press CTRL + C to exit
Navigate to http://localhost:4994 to configure the CLI.
The image below shows the dialog for adding new credentials (press on the + sign in the upper left corner)
You can get the application credentials from your developer or operator cockpit in Insights Hub. (if you don't have any application you can register a dummy one just for CLI)
Once configured you can press CTRL + C to stop the configuration server and start using the CLI. Remember the passkey you have created ,as you will be using it with almost all CLI commands.
Passkey as environment variable¶
If you don't want to enter your passkey all the time you can also set it up as Environment Variable `MDSP_PASSKEY'
This will save you the typing of the
--passkey option most of the time. Remember that this is not as secure as typing it in. Use with care.
The results of the commands will be colored in magenta if you are using Application of Service Credentials.
Session Cookie - XSRF-Token configuration¶
You can also use the SESSION Cookie and XSRF-TOKEN from the application you are developing in the CLI. Just configure following environment variables.
export MDSP_HOST="mytenant-myapp.eu1.mindsphere.io" export MDSP_SESSION="ZDcyMWVkNjMtYXXXXXXXlkYmQtODYxZDljZjIzOGI1" export MDSP_XSRF_TOKEN="33771ee2-9650-XXXX-ab73-10f52cad12bf"
set "MDSP_HOST=mytenant-myapp.eu1.mindsphere.io" set "MDSP_SESSION=ZDcyMWVkNjMtYXXXXXXXlkYmQtODYxZDljZjIzOGI1" set "MDSP_XSRF_TOKEN=33771ee2-9650-XXXX-ab73-10f52cad12bf"
$Env:MDSP_HOST="mytenant-myapp.eu1.mindsphere.io"; $Env:MDSP_SESSION="ZDcyMWVkNjMtYXXXXXXXlkYmQtODYxZDljZjIzOGI1"; $Env:MDSP_XSRF_TOKEN="33771ee2-9650-XXXX-ab73-10f52cad12bf";
The results of the commands will be colored yellow if you are using SESSION / XSRF-TOKEN type of authorization.
The use of Service or Application credentials always takes precedence over Session Cookie / XSRF-TOKEN Authentication.
You can use the Mindsphere Auth Helper Chrome extension ( chrome web store ) to simplify the copying of the authentication cookies. The extension already provides the cookies in the proper format for the CLI so that you don't have to craft the MDSP_HOST, MDSP_SESSION and MDSP_XSRF_TOKEN variable manually.
Connect and Collaborate with Industrial Professionals and Join the Community!