TsgcWSAPIClient_MCP › Events › OnMCPAuthorizationCredentials
Fires to load or store the credentials of an authorization server.
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
—
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.
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;