By Guest on Monday, 20 March 2023
Posted in General
Replies 14
Likes 0
Views 1.5K
Votes 0
how can you send the token in the header with the connection with signalr
Hello,

Configure the TsgcWebSocketClient to send the Bearer token in the Authentication property (enable only the Token section of the authentication property)


oClient := TsgcWebSocketClient.Create(nil);
oClient.Authorization.Enabled := true;
oClient.Authorization.Token.Enabled := true;
oClient.Authorization.Token.AuthToken := 'your token';
oClient.Authorization.Basic.Enabled := false;
oClient.Authorization.URL.Enabled := false;
oClient.Authorization.Session.Enabled := false;
.....


Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
And is there an option to skip negotiation?
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
No, the handshake is mandatory using the websocket protocol
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hub clients usually have this property.

I am getting a 404 not found in negotiation.Why can it be happening?

thank you very much for the previous answers
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

OK, you mean during the signalr negotiation not during the websocket handshake, sorry for misunderstanding. Currently is not supported to pass a bearer token during the negotiation but I'll implement for the next release.

Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

I've implemented the Bearer Token as SignalR Authentication, this will be included in the next release, I plan to publish the new release the next week.

Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

Thank so much for the new implementation. If cant skip negotiation i will need it.

But im trying to connect to a Hub developed in .NET6 and i always receive 404 not found.

Attach:
-vStudio project with the Hub in .Net 6 and a Console app client to the hub
-Delphi project based on Demos/02.WebSocket_protocolos/07.SignalR_Server_and_Client/delphi

I have captured the traffic from the two clients and the esegece client always does the negotiation with "/signalr". You can see in the screenShoots

How could I call the attached hub from the esegece client?

Kind Regards,
Miguel
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

Ok, I see, the problem is SignalR has changed the protocol in the latest versions, so this requires to implement those changes in the SignalR protocol. I will let you know when you can test the new version.

Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

Forget the previous post, the component you need is SignalRCore, not SignalR. I've modified your sample to use SignalRCore client, with this component the client can connect to the SignalR Server.

https://www.esegece.com/download/samples/signalr_core.zip

More info about SignalRCore client:

https://www.esegece.com/help/sgcWebSockets/#t=Components%2FAPIs%2FAPI%2FAPI_SignalRCore.htm

Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Sergio,
Its works fine. Even i receive the authorization token in the negotiation. Thanks so much.
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Sergio,


It is possible to send the authorization header in the next calls instead of as a queyr parameter.
In my case I do not allow receiving the token by parameter for security reasons.

thank you so much


VersiĆ³n: 2023.3.0: 2023 April
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

Do you mean passing the token as an Authorization Bearer Token Header (instead of a query parameter)? yes, it's possible, I can create a property to handle this behaviour.

Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Yeah that's what I meant to say
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

Yes, I've added this feature to the latest beta.

Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post