'How to pass auth token while connecting to socket.io using postman?
This is how I've been adding my auth creds (map) to a socket in socket.io:
socket = io(
url.toString(),
OptionBuilder()
.setTransports(['websocket'])
.disableAutoConnect()
.enableForceNew()
.enableForceNewConnection()
.setAuth({"token": token})
.build());
Although there is no such auth option while connecting using POSTMAN. I tried setting a "auth" header and then passing the token there, but that did not work either. Then I tried to send a "auth" header with {"token" : TOKEN}, that did not work.
Solution 1:[1]
Now days the object auth is not supported by Postman yet, insted you must use the raw websocket and send the message 40{"token":"123"} who is the package format to send a connection with token.
Here is a discussion about how to send authentication paylod https://github.com/socketio/socket.io/discussions/4072
Here is information about socket.io protocol https://github.com/socketio/socket.io-protocol
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rafael Vigueras |
