eclipse-paho / eclipse-paho/paho.mqtt.javascript
Can't send token for Authorization
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 466
- PR merge metrics
- No merged PRs in 30d
Description
When making web socket connection we can pass a token as a second parameter but I dont find any way to pass a token using paho constructor. Any possibility?
Only way left is to pass it as a param to host url like this which is insecure and would be implemented manually on server.
```
const wsUrl = "ws://server.example.com/ws?ws_token="+ws_token
var client = new Paho.MQTT.Client(wsUrl);
```
We can pass a token like this in websocket connection
`const ws = new WebSocket('ws://server.example.com/ws',['tokenString'])`
this will send token as standard Sec-WebSocket-Key
```GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
```
But there is no way to pass this token in Paho constructor.
Contributor guide
Assessment
This issue has not been assessed yet.