Skip to main content

Using The Service

warning

Due to data transmitted via MQTT being volitile some data may not be persisted across reconnections, network interruptions, and/or service outages.

Requirements

As explained in the Authentication page, you will need to request a set of Client Credentials from an authorized reseller. Once you have the Client ID, Client Secret, and API Key you can start building.

Getting an Access Token

To get an Access Token, perform a

POST
request to the token URL https://auth.weightron.cloud/oidc/token providing the grant_type, client_id, and client_secret in the body. A scope can also be provided if necessary.

An API Key is not required for the token request.

When using Postman, set the body type to x-www-form-urlencoded and add each key required and its value. Under the Authorization tab, select No Auth.

note

Under the Authorization tab, you can select OAuth 2.0 and enter your credentials under Create New Token.

Variables are used in the example below to hide the ID and Secret values.

Token Request GIF

A JSON response is returned containing the Access Token and the number of seconds until token expiry.

Response
{
"access_token": "<ACCESS_TOKEN>",
"expires_in": 300,
"token_type": "Bearer"
}

Using an Access Token

An access token is required for authentication with our MQTT service. The access token is passed as the password when making a connection to the MQTT broker.

info

MQTT Explorer is a comprehensive MQTT client that provides a structured overview of your MQTT topics and makes working with services simple. You can download MQTT Explorer here.

Using MQTT Explorer you can test your connection to the MQTT service and publish/subscribe to topics. To start, first create a new connection. and enter the following details:

image

FieldValueDescription
Namen/aA name for the connection, not required.
Validate CertificatetrueThis should be enabled when using MQTT Explorer.
Encryption (tls)trueThis should be enabled when using MQTT Explorer.
Protocolws://As encryption is required to connect to our MQTT service, secure WebSockets via wss:// (ws:// in MQTT Explorer) must be used.
Hostmqtt.weightron.cloudThe URL of our MQTT service.
Port443The port to use to connect to the MQTT service.
BasepathmqttThe basepath to be appended to the Host.
UsernameYour Application IDThe username is your Application ID (not Client ID), if you have any issues with the Application ID, please Contact Us.
PasswordYour Access TokenThe password is the access token received from the previous step.

After entering the details above, click ADVANCED and enter the topic you want to subscribe to, as per our Subscribing article.

image

Click the ADD button to add the topic to the list and when done click BACK to return to the connection screen.

You can now click CONNECT to connect to the MQTT service. If successful, you will see a green connection status in the top right, as well as the topics you have subscribed to if data is being received or has persisted internally.