Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To authenticate to ClearBlade IoT Core, each device must prepare a JSON Web Token (JWT, RFC 7519). JWTs are used for short-lived authentication between devices and the MQTT or HTTP bridges. This page describes the ClearBlade IoT Core requirements for the contents of the JWT.

ClearBlade IoT Core does not require a specific token generation method. A good collection of helper client libraries can be found on JWT.io.

When creating an MQTT client, the JWT must be passed in the password field of the CONNECT message. When connecting over HTTP, a JWT must be included in the header of each HTTP request.

...

Code Block
{Base64url encoded header}.{Base64url encoded payload}.{Base64url encoded signature}

The following sample illustrates how to create a ClearBlade IoT Core JWT for a given project. After creating the JWT, you can connect to the MQTT or HTTP bridge to publish messages from a device.

C++GoJavaNode.jsPython

View on GitHub Feedback

...

JWT

...

JWT header

The JWT header consists of two fields that indicate the signing algorithm and the type of token. Both fields are mandatory, and each field has only one value. ClearBlade IoT Core supports the following signing algorithms:

...

Refreshing JWTs

As described in required claims, tokens have expiration dates. If a device is connected over MQTT and its token expires, the device automatically disconnects from ClearBlade IoT Core. You can prevent the device from disconnecting by automatically refreshing its token. The following samples illustrate how to check whether a token has expired and, if it has, how to reconnect with a new token without disconnecting the device.

JavaNode.jsPython

View on GitHub Feedback

...