doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
729 stars 125 forks source link

Request Headers not getting set #217

Closed cakesoft-raghav closed 2 years ago

cakesoft-raghav commented 2 years ago

I am trying to set authorization bearer token using the ClientWebSocketOptions but the header is not showing up on the server side.

Here is the snippet -

socketIO = new SocketIO(connectionUrl)
{
    ClientWebSocketProvider = () =>
    {
        var clientWebSocket = new DefaultClientWebSocket
        {
            ConfigOptions = o =>
            {
                var options = o as ClientWebSocketOptions;

                options.SetRequestHeader("Authorization", $"Bearer {bearerToken}");
            }
        };
        return clientWebSocket;
    }
};

And here is the socket object I get in io.use on the server

{
  headers: { host: 'localhost:8088' },
  time: 'xxxxx',
  address: '::1',
  xdomain: false,
  secure: false,
  issued: xxxxxx,
  url: '/socket.io/?EIO=4&transport=polling',
  query: [Object: null prototype] { EIO: '4', transport: 'polling' },
  auth: {}
}

Clearly the authorization header is missing.

I am using the latest stable 3.0.1 version of the client

doghappy commented 2 years ago

Fixed, please wait for the next release update

doghappy commented 2 years ago

https://github.com/doghappy/socket.io-client-csharp#:~:text=set%20it%20to%203-,ExtraHeaders,-null