TsgcWSPClient_MQTTMethods › Auth

Auth Method

Sends an MQTT 5.0 AUTH packet to perform or continue enhanced authentication with the broker.

Syntax

procedure Auth(aReAuthenticate: Boolean; aAuthProperties: TsgcWSMQTTAuth_Properties = nil);

Parameters

NameTypeDescription
aReAuthenticateBooleanWhen True, triggers re-authentication over an already connected session; when False, sends an AUTH packet as part of the initial challenge/response handshake.
aAuthPropertiesTsgcWSMQTTAuth_PropertiesOptional MQTT 5.0 AUTH properties (Authentication Method, Authentication Data, Reason String, User Properties). Pass nil to reuse the values configured on the component.

Remarks

Available only for MQTT 5.0 sessions that negotiated an enhanced authentication method such as SCRAM or Kerberos. The broker replies through the OnMQTTAuth event, where the application supplies the next authentication data blob until the exchange succeeds or fails. Calling Auth on an MQTT 3.1.1 connection has no effect.

Example

oAuthProps := TsgcWSMQTTAuth_Properties.Create;
try
  oAuthProps.AuthenticationMethod := 'SCRAM-SHA-256';
  oAuthProps.AuthenticationData := vClientFinalMessage;
  MQTT.Auth(False, oAuthProps);
finally
  oAuthProps.Free;
end;

Back to Methods