Wednesday, 15 January 2025
  3 Replies
  6 Visits
  Subscribe
I'm testing the newest version of sgcWebSockets in Delphi to try to connect to a socket.io server.

The server I'm connecting to is using this type of auth:
https://socket.io/docs/v4/client-options/#auth

I can't see any documentation that this type of auth is supported. I've tried using TsgcWebSocketClient Authentication.Token, but that doesn't seem to work with this type of auth.
5 hours ago
·
#2220
Hello,

It seems this auth requires to pass the token when opening the http request to get a new session, so you should use the event OnHTTPRequest of the Socket.io API, find below how to pass a bearer token example, just replace "your-token" by the correct value


procedure OnHTTPRequest(Sender: TObject; aRequest: TsgcWSSocketIOHTTPRequest);
begin
aRequest.Headers.Add('Authorization: Token your-token');
end;


If doesn't work, and you can provide the server where you must connect please provide more details and I'll check in my machine.

Kind Regards,
Sergio
5 hours ago
·
#2221
Hi. It's not a part of the headers. It's sent during the CONNECT in the protocol. See the example here under 'with an additional payload':
https://socket.io/docs/v4/socket-io-protocol/#connection-to-a-namespace
5 hours ago
·
#2222
It is possibly also a part of the handshake outside of the header. See info here:
https://socket.io/docs/v4/server-socket-instance/#sockethandshake

Similar to the HandShakeTimestamp you've already implemented.
  • Page :
  • 1
There are no replies made for this post yet.
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below.
Supported: gif,jpg,png,jpeg,zip,rar,pdf,pas,dfm,dpr,dproj,dpk
· Insert · Remove
  Upload Files (Maximum 10MB)