.. _Security: ######## 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. .. http:post:: https://{hostIp}:7081/token **Example request**: .. sourcecode:: http POST /token HTTP/1.1 Accept: application/json Content-Type: application/x-www-form-urlencoded client_id=admin&client_secret=secret1 **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "token_type": "bearer", "access_token": "", "expires_in":3600.0, "expires":"2022-06-16T14:09:06.8912011Z" } :statuscode 200: OK :statuscode 400: Bad Request. A descriptive error comes along with this error. :statuscode 500: Internal Server Error :resheader Content-Type: defines the serialization format for the response body (this depends on the :mailheader:`Accept` header of the request) :>json string token_type: 'bearer' :>json string accessToken: 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. :>json double expires_in: expiration time of access token in seconds :>json datetime expires: 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) `_ .