TsgcHTTP_OAuth2_Client › Events › OnDeviceCode
Fires when the Device Code flow issues the user code that must be entered on a secondary device (RFC 8628).
property OnDeviceCode: TsgcOnAuth2DeviceCode;
// TsgcOnAuth2DeviceCode = procedure(Sender: TObject; const DeviceCode, UserCode, VerificationURI, VerificationURIComplete : String; const ExpiresIn, Interval: Integer) of object
—
OnDeviceCode is raised once the authorization server has accepted the device authorization request (RFC 8628) and returned the user/device codes. The application must display UserCode and VerificationURI to the end user so they can open the URI on a phone or computer and type the code. VerificationURIComplete is an optional convenience URL that embeds the code as a query-string parameter and is suitable for rendering as a QR code. DeviceCode is the opaque handle the component uses internally when it polls the token endpoint; the application normally does not need it. ExpiresIn is the lifetime of the user code in seconds, and Interval is the minimum polling interval in seconds requested by the server.
procedure OnOAuth2DeviceCode(Sender: TObject; const DeviceCode, UserCode, VerificationURI,
VerificationURIComplete: string; const ExpiresIn, Interval: Integer);
begin
// display the user code and the URI the user must visit on a secondary device
Memo1.Lines.Add('Go to ' + VerificationURI + ' and enter code: ' + UserCode);
Memo1.Lines.Add(Format('The code expires in %d seconds.', [ExpiresIn]));
end;