This API uses a special type of OAuth for authentication: a password grant. This kind of OAuth can be addressed with 2 successive API calls
- First, a call to the authentication server to retrieve a token
- Then, a call to the control API, using the token for authentication, to control the LED light bars.
Two interface assets have been created to enable these two steps. The rest of this article details how to make the calls.
The first call is for retrieval of the OAuth token that will be used afterwards to control the LED light bars.
The web service to call is a POST for the oauth2/token endpoint, see documentation here. On the test device we used, the default username & password of the device were admin.
Here we use the IAdea "token" interface asset to collect the parameters and make the POST.
This call results in the delivery of an access token that is accessible via the access_token property of the IAdea "token" interface asset.
Light bars control
To make it easier to reuse this access token, a Global Variable is bound to the access_token property of the "token" Interface Asset.
A Text Manipulation converter enables the addition of the keyword Bearer in front of the token.
This variable can then be used directly as a header authorization parameter for the light control calls accessible through the IAdea "light" interface asset
The additional light control parameters are
- name: use the string "frame" to specify that the call is intended to control the LED light bars on the frame; this parameter is mandatory
- brightness: 0 to turn the light off, 1 to turn them on
- color: the hexadecimal code of the color to apply to the lights.
You can download below:
- A full Intuiface sample here that will control the light bars on your IAdea device.
- The individual Interface Assets file to add to your experience
To use these Interface Assets in your own projects, see our article about reusing interface assets.