Skip to content

Acquiring an Agent Access Token via MindConnect MQTT Agents

An onboarded MindConnect MQTT agent can request an agent access token using the Agent Management Async API. The steps shown here assume that this is already accomplished.

Preparation

Update the following fields with appropriate values before using the samples given in this section:

  • <requestId>
  • <tenantId>
  • <clientId>
  • <AgentCertificate.Subject.CommonName>

Getting Agent Access Token

Agent Management Async API provides the below described topics to get an agent access token.

  1. Subscribe to the following topic to get an agent access token

    MQTT agent needs to subscribe to the following topic to get an auto-generated agent access token.

    EU1
    <clientId> = <tenantId>_<AgentCertificate.Subject.CommonName>
    Topic Structure: tc/{tenantId}/{clientId}/i/agm_v3/tr

    EU2
    <clientId> = <AgentCertificate.Subject.CommonName>
    Topic Structure: devices/{clientId}/messages/devicebound/agm_v3=tr

    Agent Management Async API will return message to device like following format.

    {
    "id": "01G16N3FBCXMCBPHYPT9RZA9S1",
    "correlationId": "01G16N3FBBDEQ7GQB2YCB3G80J",
    "requestId": "request1",
    "data": {
    "access_token": "eyJraWQiOiJrZXktaWQtidHlwIjoiXXXXXT1IE1qcxHgNrU1HzZJo ",
    "token_type": "Bearer",
    "expires_in": 3600,
    "scope": ["mdsp:core:DefaultAgent"],
    "jti": "16c4229a275e43b08551cc322deb72a8",
    "timestamp": 1650564644
    }
    }
    
  2. Publish a message to the following topic to request an agent access token.

    MQTT agent needs to publish a message to the following topic to request an auto-generated agent access token.

    EU1:
    <clientId> = <tenantId>_<AgentCertificate.Subject.CommonName>
    Topic Structure: tc/{tenantId}/{clientId}/o/agm_v3/t

    EU2:
    <clientId> = <AgentCertificate.Subject.CommonName>
    Topic Structure: devices/{clientId}/messages/events/agm_v3=t

    Sample message body:

    {
    "id": "<requestId>"
    }
    

Any questions left?

Ask the community


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


Last update: May 27, 2022