![Daikin Airzone Скачать руководство пользователя страница 10](http://html1.mh-extra.com/html/daikin/airzone/airzone_api-integration-manual_502360010.webp)
API Integration Manual for Daikin DKN Cloud Wi-Fi Adaptor
9
curl --location --request POST "https://www.dkncloudna.com/api/v1/open/oauth2/token" \
--header "Content-Type: application/x-www-form-urlencoded" \
--form "grant_type=authorization_code" \
--form "client_id=CLIENT_ID” \
--form "client_secret=CLIENT_SECRET" \
--form "code=CODE"
-
RESPONSE: This returns a JSON object, with the following four properties:
o
access_token
: token used in every request made to the API to authenticate the request in
behalf of the user.
o
token_type
:
Doesn’t apply; its value will always be:
Bearer
o
expires_in
: (Number) value in seconds specifying the lifetime of the token. By default, it will
be two hours
o
refresh_token
: used for requesting a new access token when this one expires.
Example response:
{
"refresh_token": "R7k6xX3HsHH1LIPYrCV5SbtYNH7rzFlb",
"token_type": "bearer",
"access_token": "duUB2GpPoEg5dBRg2giWfFb0EvBFKg3Q",
"expires_in": 7200
}
Reached this point, the third party application is authorized to access the DKN Cloud NA
environment through the Open API endpoints on behalf of the user.
When the access token expires, DKN Cloud NA will respond with 401 error codes to every request,
with the following JSON body:
{
"_error_description": "The access token is invalid or has expired",
"error": "invalid_token"
}
The third party service will then need to request a new access token for the user. In order to do so,
the service must use the value of the
refresh_token
property obtained in the response body of the
previous request, and use it as shown in the following request:
-
REQUEST:
-
POST
https://www.dkncloudna.com/api/v1/open/oauth2/token
-
HEADERS:
o
Content-Type: application/x-
ẃww-form-urlencoded
o
Accept: application/json
-
BODY: application/x-www-form-urlencoded type body parameters:
o
grant_type
: (String) its value must be "
refresh_token
".
o
client_id
: (String) value of the
client_id
token issued for the entity.
o
client_secret
: (String) value of the
client_secret
token issued for the entity.
o
refresh_token
: (String) value of a valid refresh token for that user.
-
EXAMPLE:
curl --location --request POST "https://www.dkncloudna.com/api/v1/open/oauth2/token" \
--header "Content-Type: application/x-www-form-urlencoded" \