Create token for MQTT

The create tokens for MQTT request allows the client application to create tokens for MQTT devices.

You can generate three types of token for MQTT. Following are the auth types:

  • U: The auth type is U, when username and password are provided.

    For example: If username provided is testP, and secret provided is TESTP, then the auth type will be U.

  • S: The auth type is S, when only username is provided, and password is system generated.

    For example: If username provided is US5591USRS91 and secret is not provided, then the auth type will be S.

  • SN: The auth type is SN, when username is provided as #SN#, and password may or may not be provided. If provided, the password will be ignored, and the system generates the username and password.

    For example: If Username provided is #SN#86a39134-e151-4490-aff1-3d7e994151d1, and secret provided/not provided, the auth type will be SN.

Table 1. Auth types
Auth type Username Password
U Yes Yes
S Yes No
SN #SN# Yes/No (ignored if provided)

MQTT-AL tokens are created from http://<impact_url>/m2m/token/mqtt

Create MQTT token for the user describes the API structure for creating MQTT token for the user.

Table 2. Create MQTT token for the user
Title Create MQTT token for the user
URL http://<impact_url>/m2m/token/mqtt
Method PUT
Content-Type application/json
URL Params

The following are the URL parameters:

  • description:[string]: Specifies the description for the token created

  • groupName:[string]: Specifies the group name for which the tokens must be created.

  • username:[string]: Specifies the user who creates the tokens.

Data Params

msg:[string]: Success or failure message

tokenResponse:[string]: Specifies the list of tokens created for a group

Success Code
Response Code: 202
Error Code
201 : Created 
401 : Unauthorized 
403 : Forbidden 
404 : Not Found
Sample Call

Curl:

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json'  --header 'Authorization: Basic amFpX21mb3JtYWRtaW46bWZvcm1RMXcyZSM=' -d '{
   "description": "testtoken",
  "groupName": "DM.MFORM.SURYA",
  "username": "test12345"
}' 'http://mfussip02.mformation.com:9090/m2m/token/mqtt'
Response Body:
{
  "msg": "Success",
  "tokenResponse": {
    "token": "1jylmg8lwa1cy",
    "secret": "iJ6ZIaJNUsILm3WGNr55LDDCV3iQ+RjmOcQbY2IGquY=",
    "username": "TEST12345",
    "description": "testtoken"
  },"code":1000
}
Notes
  • The password given in the request is validated for length and
    • If the length is less than 5 characters, then the following message appears:

      'password' can not be less than 5 chars
    • If the length is more than 50 characters, then the following message appears:

      'password' can not be more than 50 chars
  • If length of username given in the request, is more than 50 characters, following message appears:

    ‘username' can not be more than 50 chars