TsgcWSAPIClient_MCP › Events › OnMCPAuthorizationCredentials

OnMCPAuthorizationCredentials Event

Fires to load or store the credentials of an authorization server.

Syntax

property OnMCPAuthorizationCredentials: TsgcAI_MCP_Client_OnAuthorizationCredentialsEvent;
// TsgcAI_MCP_Client_OnAuthorizationCredentialsEvent = procedure(Sender: TObject; const aIssuer: string; const aCredentials: TsgcAI_MCP_Client_AuthorizationCredentials; aSave: Boolean) of object

Default Value

—

Remarks

With aSave False the event is raised the first time an issuer is used: fill aCredentials with the values you stored before (ClientId, ClientSecret, AccessToken, RefreshToken, ExpiresAt, Scope, Registration). With aSave True it is raised after a registration, a new token or a refresh: store the values. Credentials are kept per issuer.

Available only when the library is compiled with OAuth2 support (define SGC_OAUTH). See Authorization.

Example

procedure TMainForm.MCPAuthorizationCredentials(Sender: TObject;
  const aIssuer: string;
  const aCredentials: TsgcAI_MCP_Client_AuthorizationCredentials;
  aSave: Boolean);
begin
  if aSave then
    FStore.Values[aIssuer] := aCredentials.RefreshToken
  else
    aCredentials.RefreshToken := FStore.Values[aIssuer];
end;

Back to Events