How to pass auth token while connecting to socket.io using postman?

Viewed 1758

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.

2 Answers

If want to use socketIO postman. instead of saving token in auth, you can send with header.

const token = socket.handshake.headers.access_token;

Postman request

1

Related