Security

Authentication and Authorization

The API uses OAuth 2.0 as authorization protocol. Clients must pass a valid bearer access token in the Authorization header for api calls to succeed.

After expiration of the access token, a new token must be requested. While requesting a token, the client id and secret must be given.

An access token can be requested as follows:

URL parameters

  • hostIp: Ip address of the API host.

POST https://{hostIp}:7081/token

Example request:

POST /token HTTP/1.1
Accept: application/json
Content-Type: application/x-www-form-urlencoded

client_id=admin&client_secret=secret1

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "token_type": "bearer",
   "access_token": "<access-token>",
   "expires_in":3600.0,
   "expires":"2022-06-16T14:09:06.8912011Z"
}
Status Codes:
Response Headers:
  • Content-Type – defines the serialization format for the response body (this depends on the Accept header of the request)

Response JSON Object:
  • token_type (string) – ‘bearer’

  • accessToken (string) – access token to be used in protected api calls. This access token also contains the role claim used by the api to determine if the client is authorized to execute the request method.

  • expires_in (double) – expiration time of access token in seconds

  • expires (datetime) – expiration date of access token (utc).

Roles

The api supports 2 types of client roles:

  • Operator : clients with the operator role can execute operations on the defined devices.

  • Administrator : clients with the administrator role can manage api settings (future implementation) besides executing operations on the defined devices.

The role of a client can be configured through ALIOT (Alphatronics’ Iot solution) .

Cors

By default all hosts are enabled. This can be changed through ALIOT (Alphatronics’ Iot solution) .