TsgcHTTP_OAuth2_ServerEvents › OnOAuth2AfterRefreshToken

OnOAuth2AfterRefreshToken Event

Fires after the /token endpoint successfully renews an access token using the refresh_token grant.

Syntax

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

Default Value

Remarks

OnOAuth2AfterRefreshToken is raised after the /token endpoint has processed a grant_type=refresh_token request and issued a new access token (and optionally a new refresh_token). Connection is the live transport, OAuth2 exposes the request context including the incoming refresh token and client_id, and aResponse contains the raw JSON payload sent back to the client with the renewed tokens. The event is intended for audit logging, token rotation tracking and refreshing external caches, and is useful to correlate each renewal with the original access-token issuance captured by OnOAuth2AfterAccessToken.

Example


procedure OnOAuth2AfterRefreshToken(Sender: TObject; Connection: TsgcWSConnection;
  OAuth2: TsgcHTTPOAuth2Request; aResponse: string);
begin
  DoLog(Format('Refresh token rotated for client %s', [OAuth2.ClientId]));
end;

Back to Events