Used for authorizing the socket connection. A successful authentication will respond with OK (17)
Authorization can be done by using either a username and password combination or by a token.
Syntax username/password
[username, password]
Syntax token
"token_string"
As an example we create an authentication package for the default admin user with password pass.
This is the package data for our authentication request:
["admin", "pass"]
Serializing the above using MessagePack results in the following 12
bytes:
\x92\xa5admin\xa4pass
Now we create the header. For this example we just use Id 0:
\x0c\x00\x00\x00
\x00\x00
\x21
\xde
Sending the Auth package
\x0c\x00\x00\x00\x00\x00\x21\xde\x92\xa5admin\xa4pass
Responding OK package
\x00\x00\x00\x00\x00\x00\x11\xee
First, a token is required and can be created using the new_token() function.
Suppose our token is RzDFlsoucQfDqrwrfGGEtc
.
Serializing the token using MessagePack results in the following 23
bytes:
\xb6RzDFlsoucQfDqrwrfGGEtc
Now we create the header. For this example we just use Id 0:
\x17\x00\x00\x00
\x00\x00
\x21
\xde
Sending the Auth package
\x17\x00\x00\x00\x00\x00\x21\xde\xb6RzDFlsoucQfDqrwrfGGEtc
Responding OK package
\x00\x00\x00\x00\x00\x00\x11\xee