TsgcWebSocket client prend en charge 4 types d'authentifications :
Il s'agit d'une méthode d'autorisation simple dans laquelle le nom d'utilisateur et le mot de passe sont encodés et transmis en tant qu'en-tête HTTP. Définissez simplement User et Password et activez uniquement le type d'autorisation Basic pour utiliser cette méthode.
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.Basic.Enabled := true; oClient.Authentication.User := 'your user'; oClient.Authentication.Password := 'your password'; oClient.Authentication.Token.Enabled := false; oClient.Authentication.URL.Enabled := false; oClient.Authentication.Session.Enabled := false; oClient.Active := True;
Vous permet d'autoriser en utilisant JWT. Cela nécessite l'obtention d'un jeton à l'aide d'un outil externe (par exemple : une connexion HTTP, OAuth2, etc.).
Si vous attachez un composant OAuth2, vous pouvez obtenir ce jeton automatiquement. En savoir plus sur OAuth2.
Vous devez définir votre AuthToken et activer l'authentification par jeton.
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.Token.Enabled := true; oClient.Authentication.Token.AuthToken := 'your token'; oClient.Authentication.Basic.Enabled := false; oClient.Authentication.URL.Enabled := false; oClient.Authentication.Session.Enabled := false; oClient.Active := True;
Le client se connecte d'abord au serveur via une connexion HTTP en demandant une nouvelle session. En cas de succès, le serveur retourne un SessionId et le client envoie ce SessionId dans l'en-tête HTTP GET du handshake WebSocket.
Nécessite de définir UserName et Password et d'activer l'authentification de session.
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.Session.Enabled := true; oClient.Authentication.User := 'your user'; oClient.Authentication.Password := 'your password'; oClient.Authentication.Basic.Enabled := false; oClient.Authentication.URL.Enabled := false; oClient.Authentication.Token.Enabled := false; oClient.Active := True;
Cette méthode d'authentification transmet le nom d'utilisateur et le mot de passe dans l'en-tête HTTP GET de la négociation WebSocket.
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.URL.Enabled := true; oClient.Authentication.User := 'your user'; oClient.Authentication.Password := 'your password'; oClient.Authentication.Basic.Enabled := false; oClient.Authentication.Session.Enabled := false; oClient.Authentication.Token.Enabled := false; oClient.Active := True;