This topic is used by the cloud to send a JWT token to the device after successful authentication via QR code scanning. The device will use this token to authenticate future communications with the cloud.
Request Topic and Payload
Topic
things5-production/v1/devices/<device-id>/authentication_token
Payload Representation
{
"access_token": {access_token},
"expires_in": 3600,
"refresh_expires_in": 1800,
"refresh_token": {refresh_token},
"token_type": "Bearer",
"id_token": {id_token},
"not-before-policy": 0,
"session_state": {UUID},
"scope": "openid profile email"
}
The cloud will publish a message to this topic after the mobile device has successfully scanned the QR code and the session has been authenticated.
Payload Parameters
type | description | example |
---|---|---|
access_token | JWT token that the device will use for authenticating HTTPS requests. | eyJhbGciOiASU-... |
refresh_token | JWT token that the device will use to keep the session active. | eyJhbGciOiASU-... |
Example response
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJWSk1CenoxVi1SSFN0SWwzbDJqcVd2WVl2NUZtbjJCSW5ySldwX2UzVzN3In0.eyJleHAiOjE3MDkyMzcyMjMsImlhdCI6MTcwOTIwMTMxNCwianRpIjoiYmUxMGUzMGYtODNlMC00NjY4LTgwYzAtZDRiYmNjOGM2OTA2IiwiaXNzIjoiaHR0cHM6Ly9rZXljbG9hay52aXN1cC5tZS9hdXRoL3JlYWxtcy90aGluZ3M1LXN0YWdpbmciLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiYTkzNTNhNjEtN2JjZS00MWYyLWE1MzctMGJmYjE1OTc4ZjU4IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiYXBpIiwic2Vzc2lvbl9zdGF0ZSI6IjMwMjMzMGJhLTg0N2EtNGNmZC05NDllLTNkZjA5ZGUwOWVkNyIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJkZWZhdWx0LXJvbGVzLXRoaW5nczUtc3RhZ2luZyIsIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY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xfdmVyaWZpZWQiOnRydWUsIm5hbWUiOiJBbmRyZWEgR3Jvc3NldHRpXHVEODNEXHVEQzEzIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYW5kcmVhQHZpc3VwLml0IiwiZ2l2ZW5fbmFtZSI6IkFuZHJlYSIsImZhbWlseV9uYW1lIjoiR3Jvc3NldHRpXHVEODNEXHVEQzEzIiwiZW1haWwiOiJhbmRyZWFAdmlzdXAuaXQifQ.NM1A9j5lNKN_jbJcpY2onumY4nARBHNbnAUI8A7WU-GvdRbUiquzLhfYDUDunH87DrEIfepqAROWN9ukcwBX9OD8bnttWr4LPrUbjtV8tfpMLBlvpY_OkvenY1hBLiOitDaKK5mvkdT1iuxS1Fv1EJinRaUYriTi1W0bp4Cx4EHCpiICjp8fQQnasiD_3y0Wq7Me9xIx0asnbtytIXbCZMrbIF750FE3EEGedm4y2vd2cB8OhObtlV5xnKJXJFhKYRsBZisfUuU-NDkx3yvR-BvS8ahHBo2d9grJLX2iU-4I_YH0frUMub8UssqF2qU34oxV2gfrrX9h_JCeIdqU2g",
"not-before-policy": 0,
"session_state": {UUID},
"scope": "openid profile email"
}
- The device should subscribe to this topic after it requests a QR code (https://docs.things5.com/reference/sub-authentication-qr-request), waiting for the JWT token after successful authentication.
- The access_token should be included in the Authorization header of all future HTTP requests made by the device.
- Ensure to handle token expiration, send your refresh_token to https://docs.things5.com/reference/refresh-token to keep your session active.