Getting TOTP key¶
To securely control device with TOTP protocol authentication, you need to know the key, which is a sequence of 16 bytes. It’s generated by the cloud at the first connection and every time you bind to the account.
- You can get it through the server API only in 2 steps:
get the authorization token for the required account
get a list of devices with parameters linked to this account
GETTING AN AUTHORIZATION TOKEN
POST https://app.welrok.com/api/login/
{
"email":"user@email.com",
"password":"myPassword"
}
- Parameters:
email - email of account
password - account password
Answer:
{
"access_token":"9573e6a8e24b025fafbaf81dc2eccbc09b94d187",
"user_name":"welrok",
"is_timezone_chosen":true
}
access_token - required authorization token
Example:
{
POST /api/login/ HTTP/1.1
Host: app.welrok.com
Accept-Language: en
Content-Type: application/json
{"email":"demo@welrok.com","password":"demoaccount"}
}
GETTING LIST OF DEVICE
GET https://app.welrok.com/api/device/ –header «Authorization: Token access_token»
- Parameters
access_token- authorization token in header
Answer:
{
"count": 4,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"sn": "404CCAAAD4E8A89860609800000149",
"name": "az",
"":""
"totp_key": "AAD4EXAJX4E8A8XT"
}
]
}
Field totp_key in parameters of every devices has required key for TOTP token generation.
Example:
{
GET /api/device/ HTTP/1.1
Host: app.welrok.com
Accept-Language: en
Content-Type: application/json
Authorization: Token 9573e6a8e24b025fafbaf81dc2eccbc09b94d187
}