TsgcHTTP_OAuth2_ServerEvents › OnOAuth2AfterAccessToken

OnOAuth2AfterAccessToken Event

Fires after the /token endpoint successfully issues an access token.

Syntax

property OnOAuth2AfterAccessToken: TsgcHTTPOAuth2AfterAccessTokenEvent;
// TsgcHTTPOAuth2AfterAccessTokenEvent = procedure(Sender: TObject; Connection: TsgcWSConnection; OAuth2: TsgcHTTPOAuth2Request; aResponse: String) of object

Default Value

Remarks

OnOAuth2AfterAccessToken is raised after the /token endpoint has successfully issued an access token for one of the supported grant types (authorization_code, client_credentials, password). Connection is the live transport, OAuth2 exposes the request context (client_id, scope, grant_type, user) and aResponse contains the raw JSON body returned to the client, including access_token, token_type, expires_in and, when enabled, refresh_token. The event is intended for audit logging, metrics, persisting issued tokens to external storage, and triggering downstream workflows such as provisioning.

Example


procedure OnOAuth2AfterAccessToken(Sender: TObject; Connection: TsgcWSConnection;
  OAuth2: TsgcHTTPOAuth2Request; aResponse: string);
begin
  DoLog(Format('Access token issued to client %s: %s',
    [OAuth2.ClientId, aResponse]));
end;

Back to Events