TsgcHTTP_OAuth2_Server › Events › OnOAuth2AfterRefreshToken
Fires after the /token endpoint successfully renews an access token using the refresh_token grant.
property OnOAuth2AfterRefreshToken: TsgcHTTPOAuth2AfterRefreshTokenEvent;
// TsgcHTTPOAuth2AfterRefreshTokenEvent = procedure(Sender: TObject; Connection: TsgcWSConnection; OAuth2: TsgcHTTPOAuth2Request; aResponse: String) of object
—
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.
procedure OnOAuth2AfterRefreshToken(Sender: TObject; Connection: TsgcWSConnection;
OAuth2: TsgcHTTPOAuth2Request; aResponse: string);
begin
DoLog(Format('Refresh token rotated for client %s', [OAuth2.ClientId]));
end;