TsgcHTTP_OAuth2_ClientEvents › OnHTTPResponse

OnHTTPResponse Event

Fires just before the local HTTP server sends the browser-facing response after the authorization redirect.

Syntax

property OnHTTPResponse: TsgcOnAuth2HTTPResponse;
// TsgcOnAuth2HTTPResponse = procedure(Sender: TObject; var Code: Integer; var Text: String) of object

Default Value

Remarks

OnHTTPResponse is raised by the embedded local HTTP server (LocalServerOptions) right before it answers the browser window that the authorization server redirected to RedirectURL. The handler can change Code (the HTTP status code, default 200) and Text (the HTML body shown to the end user) to customize the "you can now close this window" landing page, for example to match the corporate style, to localize the message, or to trigger a browser redirect to a confirmation page. The event fires for both success and error redirects.

Example


procedure OnOAuth2HTTPResponse(Sender: TObject; var Code: Integer; var Text: string);
begin
  Code := 200;
  Text := '<html><body><h2>Authorization complete</h2>' +
          '<p>You can close this tab and return to the application.</p></body></html>';
end;

Back to Events