Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Duo Auth API - Ping
See more Duo Auth MFA Examples
The /ping endpoint acts as a "liveness check" that can be called to verify that Duo is up before trying to call other Auth API endpoints.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Http;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
url: string;
jsonStr: string;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := THttp.Create;
http.Accept := 'application/json';
// Use your own hostname here:
url := 'https://api-a03782e1.duosecurity.com/auth/v2/ping';
jsonStr := http.QuickGetStr(url);
if (http.LastMethodSuccess = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
WriteLn('status code = ' + http.LastStatus);
WriteLn(jsonStr);
// Sample successful output:
// status code = 200
// {"response": {"time": 1632358295}, "stat": "OK"}
http.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.