# auth

Description: authorize the current connection.

The command is used for authenticating in multiple control modes for each type of protection.

Query example (Unprotected authorization):

{
    "method" : "auth",
    "requestId" : "1",
    "type" : "unsecured",
    "role" : "admin"
}

Query example (Secured authorization):

{
    "method" : "auth",
    "requestId" : "1",
    "type" : "secured",
    "credentials" : "some very secret string",
    "role" : "user"
}

Query example (Status change from administrator to user):

{
    "method" : "auth",
    "requestId" : "1",
    "role" : "user"
}

Response example:

{
    "method": "auth",
    "requestId" : "1",
    "previleges": 2,
    "token": "1*Cwk7m2fznHFi0t02*99235446*4145443734323733424642364342343533393737393543374636333936383238",
    "tokenForHttpServer": "4*MKYl5cDyBcJrKUez*96643746*4139444242343336304535343243323846374130304337424641464139394633",
    "result": true,
    "resultCode" : 0
}

Parameter description:

  • type - type of authentication. Depending on the type of authentication, the parameter takes the following values:

    • Secured authentication - the value should be equal to secured, can be by password, by PIN or by token. In this case, you need to specify the corresponding PIN, password or token in the credentials parameter.

    • Unsecured authorization — the parameter is present and the value will be equal to unsecured

    • Status change from administrator to user — is not included

  • role - purpose. Depending on the type of authorization, the parameter takes the following values:

    • Secure authorization, Authorization without protection - optional parameter. If present, indicates the resulting connection mode to be obtained (admin or user) and serves as its verification. If the parameter is not present, the mode will be assigned automatically and without checks.

    • Status change from administrator to user — required and must be equal to admin

  • credentials - depending on the authentication method, contains a password, a PIN, or a token.

  • resultCode - the result of authorization, takes the following numerical values:

    • 0 — Successful

    • 1 — Internal failure

    • 2 - authorization error due to the current plan not being Pro

    • 3 - authorization error due to the fact that the current connection is not authorized as admin

    • 4 - Authorization error due to the fact that according to the current authorization data, this type of security cannot be used.

    • 5 - Authorization error due to the fact that after authorization, privileges will be obtained that are different from those required.

    • 6 - authorization is unavailable due to frequent input of incorrect password. You need to wait before attempting to authorize again.

    • 7 - authentication error due to empty credentials

    • 8 - authorization error due to incorrect credentials

    • 9 - authorization error due to an invalid value of the role field.

    • 10 - authorization error due to an invalid value of the type field

    • 11 - authorization error because the type parameter is missing.

    • 12 - authorization error due to missing credentials parameter

  • previleges — the resulting management mode. The following options are possible:

    • 1user

    • 2administrator

  • token — the token of the current connection that should be used in the API. It may be used for token authorization when the connection is lost and a new connection is established. The token lifetime depends on the type of authorization:

    • Unsecured authorization — 30 days or until the moment when the application is closed

    • with a password — 30 days or until the moment when the application is closed

    • with a PIN — 30 days or until the moment when the application is closed

    • with a PIN entered from the command line — until the moment when the application is closed

    • By token - determined by the initial authorization during which it was obtained.

    • Switch to user from administrator - determined by the initial authorization during which it was obtained

  • tokenForHttpServer — the current connection token. It will be used on the HTTP server. The token lifetime equals 5 minutes or until the moment when the application is closed

  • requestId - unique request identifier. More details can be found here

See also: