Get QR code via websocket#
Along with getting a QR code using QR method, it is possible to get a QR code via websocket connection. Timeout for scanning a QR code is 100 seconds. During this time, the QR code must be scanned. To get a QR code, the instance must be in an unauthorized state. If the instance is authorized, you have first to log out the instance using Logout method.
After successful scanning a QR code and authorizing the instance, an incoming notification in the form of Instance Status is generated.
To get QR code you have to establish a websocket-connection at:
WSS:
{{apiUrl}}/waInstance{{idInstance}}/scanqrcode/{{apiTokenInstance}}
For apiUrl
, idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Example of getting a QR code in a browser#
You can see an example of getting a QR code through websocket in the file websocketExampleQRcode
Response#
Response parameters#
Parameter | Type | Description |
---|---|---|
type | string | Message type, possible variants qrCode , error , accountData , alreadyLogged , timeout |
message | string | Message content. Takes on different values depending on parameter type |
Got QR code#
Parameter | Type | Descroption |
---|---|---|
type | string | qrCode - got QR code image |
message | string | base64 QR code image. To display in the browser, you need to add a string data:image/png;base64, {message} |
Error occurred#
Parameter | Type | Description |
---|---|---|
type | string | error - an error is occurred |
message | string | Error description |
Instance already authorized#
Parameter | Type | Description |
---|---|---|
type | string | alreadyLogged - instance is already authorized. To get a QR code, you have first to log out of your instance using Logout method |
message | string | akes on the value instance account already authorized |
QR code scan timeout expired#
Parameter | Type | Description |
---|---|---|
type | string | timeout - the timeout within which a QR code must be scanned has expired. Timeout for scanning a QR code is 100 seconds. |
message | string | Takes on the value timeout |