From sgcWebSockets 4.4.8 JWT is supported on Client components like WebSocket Client and HTTP/2 Client.
The TsgcHTTP_JWT_Client component allows to encode and sign JWT Tokens, attached to a WebSocket Client or HTTP/2 client, the token will be sent automatically as an Authorization Bearer Token Header.
Configuration
You can configure the JWT values in the JWTOptions properties, there are 2 main properties: Header and Payload, just set the values for every required property.
If the Signature is encrypted using a Private Key (RS and ES algorithms), set the value in the PrivateKey property of the Algorithm.
If the Signature is encrypted using a Secret (HS algorithms), set the value in the Secret property of the Algorithm.
Custom Headers
The Header and Payload properties contains the most common headers used to generate a JWT, but you can add more headers calling the method AddKeyValue and passing the Key and Value as parameters.
Example: if you want add a new record in the JWT Header with your name, use the following method
Header.AddKeyValue('name', 'John Smith');
After configuring the properties, to generate the JWT, just call the method Sign and will return the value of the JWT.
WebSocket Client and JWT
TsgcWebSocketClient allows the use of JWT when connecting to WebSocket servers, just create a new JWT client and assign to Authentication.Token.JWT property.