Device tokens

Show a QR code that lets users get access to the device.

These MQTT resources allow a device to generate a device token that can be used by a user to associate the device to his account. Token will be generated following policies defined at organization level on things5 such as if the token is single use or can be use multiple times and the role related to the token.

The user must use Device tokens consume to authorize the session

TopicDirection
things5-production/v1/devices/{device_id}/req/generate_device_token_from_policies_reqDevice → Things5
things5-production/v1/devices/{device_id}/req/generate_device_token_from_policies_resThings5 → device

Device → Things5: req/generate_device_token_from_policies_req

Given a device and an organization use organization policies to generate a device token that will be returned as a QR code. Scanning the qr code will consume the token and associate the device to the user

things5-production/v1/devices/<device-id>/req/generate_device_token_from_policies_req

Payload

{
  "request_id": "87049f68-696f-4be8-a6cc-bf827c04ed0e",
  "type": "qr",
	"things5_host": "myorganization.com",
	"organization_id": "50867a80-c228-4db6-9fec-15bd72efc83a"
}

The request_id will be returned in the response. It can be used to match the request with the response. Should be random generated.

Payload Parameters

namedescriptionexample
request_idthe request id to be sent back by the device when sending the response
typetype of response that will be sent. Qr is only type supported right now
organization_idthe organization where the device
things5_hostoptional. If provided the qr code response will contain a url build using things5_host instead of text data.

Things5 → device: req/generate_device_token_from_policies_res

things5-production/v1/devices/<device-id>/req/generate_device_token_from_policies_res

Payload

{
  "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
  "errors": [],
  "request_id": "87049f68-696f-4be8-a6cc-bf827c04ed0"
}

Payload Parameters

typedescriptionexample
datadata containing the session_id. if qr type was requested it's a base64 format string. Otherwise an encoded json
request_idThe request id sent in the authentication_qr_req87049f68-696f-4be8-a6cc-bf827c04ed0e
errorsarray of strings.