TsgcWebSocketClient | Client Authentication

TsgcWebSocket client supports 4 types of Authentications:

 

 

Authorization Basic

This is a simple authorization method where user and password are encoded and passed as an HTTP Header. Just set the User and Password and enable only the Basic Authorization type to use this method.


oClient := TsgcWebSocketClient.Create(nil);
oClient.Authorization.Enabled := true;
oClient.Authorization.Basic.Enabled := true;
oClient.Authorization.User := 'your user';
oClient.Authorization.Password := 'your password';
oClient.Authorization.Token.Enabled := false;
oClient.Authorization.URL.Enabled := false;
oClient.Authorization.Session.Enabled := false;
oClient.Active := True;

 

Authorization Token

Allows you to authorize using JWT. This requires you to obtain a token using an external tool (for example: an HTTP connection, OAuth2, etc.).

If you attach an OAuth2 component, you can obtain this token automatically. Read more about OAuth2.

You must set your AuthToken and enable Token Authentication.


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;
oClient.Active := True;

 

Authorization Session

First the client connects to the server using an HTTP connection requesting a new Session. If successful, the server returns a SessionId and the client sends this SessionId in the GET HTTP Header of the WebSocket HandShake.

Requires setting the UserName and Password and enabling Session Authentication.


oClient := TsgcWebSocketClient.Create(nil);
oClient.Authorization.Enabled := true;
oClient.Authorization.Session.Enabled := true;
oClient.Authorization.User := 'your user';
oClient.Authorization.Password := 'your password';
oClient.Authorization.Basic.Enabled := false;
oClient.Authorization.URL.Enabled := false;
oClient.Authorization.Token.Enabled := false;
oClient.Active := True;

 

Authorization URL

This authentication method passes the username and password in the GET HTTP Header of the WebSocket HandShake.

 


oClient := TsgcWebSocketClient.Create(nil);
oClient.Authorization.Enabled := true;
oClient.Authorization.URL.Enabled := true;
oClient.Authorization.User := 'your user';
oClient.Authorization.Password := 'your password';
oClient.Authorization.Basic.Enabled := false;
oClient.Authorization.Session.Enabled := false;
oClient.Authorization.Token.Enabled := false;
oClient.Active := True;