set parameter for handshake.auth.token
I have question On server
io.on('connection', function (socket) {
console.log('token: ' + socket.handshake.auth.token);
});
My question is how to set parameter on ios client since there is no enum for auth i have tried
SocketManager(socketURL: URL(string: "https://xxxx/")!, config: [.log(true), .compress, .path("/api/messenger/socket.io"), .connectParams(["token": Auth.token]))
but not work always fail
data = {
content = "Authentication error 01";
};
message = "not authorized";
I tried the same as @ajijoyo and also got the same "not authorised" message. Please advise how to set the parameter for the handshake.auth.token.
got the same problem, did you guys manage to make it work?
actually, I didn't solve it, I suggested server to read from header instead
If anyone is still interested, I solved it with the following:
let manager = SocketManager(socketURL: url, config: [.compress])
manager.socket.connect(withPayload: ["auth": "xxx"])
Yeah, I ended up doing the same thing. It appears that passing the auth info via payload when connecting does the job!
@nzapponi is it still working for you with latest socket library ?
I’m trying to use code sample which you provided and it won’t compile because can’t find such method .
@nzapponi thanks man. that works. I'm using the latest version.