You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: configuration/websocket.md
+13-4
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,23 @@ All messages on the WebSocket connection are JSON encoded text-messages.
12
12
## Establishing a connection
13
13
14
14
WebSockets are available on the same ports as the REST API, usually port 8080 for unsecured (ws-protocol) and port 8443 for secured (wss-protocol) connections.
15
-
The connection is established by connecting to `ws[s]://{URL}:{PORT}/ws?accessToken={TOKEN}`.
15
+
The connection is established by connecting to `ws[s]://{URL}:{PORT}/ws`.
16
16
17
-
To prevent unauthorized use of the connection an `accessToken` has to be sent with the initial request.
18
-
{TOKEN} can be one of these two:
17
+
To prevent unauthorized use of the connection, an access token has to be sent with the initial request.
18
+
There are two options to send the access token:
19
+
20
+
1. Through the `Sec-WebSocket-Protocol` header:<br>
21
+
As browsers cannot add `Authorization` headers to WebSocket requests but can specify WebSocket sub-protocols to send with the request.<br>
22
+
You need to set the `org.openhab.ws.protocol.default` and `org.openhab.ws.accessToken.base64.${BASE64_TOKEN}` sub-protocols, where `${BASE64_TOKEN}` is the Base64 encoded `${TOKEN}` without `=` padding.
23
+
The server will respond with the `org.openhab.ws.protocol.default` sub-protocol (as browsers require the server to select one of the provided sub-protocols).<br>
24
+
25
+
1. Through the `accessToken` query parameter: `ws[s]://{URL}:{PORT}/ws?accessToken={TOKEN}`.
26
+
27
+
`${TOKEN}` can be one of these two:
19
28
20
29
1. An API token: `oh.ohwstest.tz1IDPniKLxc0VU4t9tz4GiAiKmc0ZDdMKxhlD5tfviQStM4oNsywrcrUTktPbBE9YQ3wnMBrCqVEIhg7Q`
21
30
22
-
1. Basic Auth with base64 encoded {USER}:{PASSWORD}: `dXNlcjpwYXNzd29yZA==`
31
+
1. Basic Auth with base64 encoded `{USER}:{PASSWORD}`: `dXNlcjpwYXNzd29yZA==`
0 commit comments