TsgcWSPClient_MQTT › Methods › Auth
Sends an MQTT 5.0 AUTH packet to perform or continue enhanced authentication with the broker.
procedure Auth(aReAuthenticate: Boolean; aAuthProperties: TsgcWSMQTTAuth_Properties = nil);
| Name | Type | Description |
|---|---|---|
aReAuthenticate | Boolean | When True, triggers re-authentication over an already connected session; when False, sends an AUTH packet as part of the initial challenge/response handshake. |
aAuthProperties | TsgcWSMQTTAuth_Properties | Optional MQTT 5.0 AUTH properties (Authentication Method, Authentication Data, Reason String, User Properties). Pass nil to reuse the values configured on the component. |
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.
oAuthProps := TsgcWSMQTTAuth_Properties.Create;
try
oAuthProps.AuthenticationMethod := 'SCRAM-SHA-256';
oAuthProps.AuthenticationData := vClientFinalMessage;
MQTT.Auth(False, oAuthProps);
finally
oAuthProps.Free;
end;