Sample code for 30+ languages & platforms
C

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 C Downloads

C
#include <C_CkHttp.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttp http;
    const char *url;
    const char *jsonStr;

    success = FALSE;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttp_Create();

    CkHttp_putAccept(http,"application/json");

    // Use your own hostname here:
    url = "https://api-a03782e1.duosecurity.com/auth/v2/ping";

    jsonStr = CkHttp_quickGetStr(http,url);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        return;
    }

    printf("status code = %d\n",CkHttp_getLastStatus(http));
    printf("%s\n",jsonStr);

    // Sample successful output:

    // status code = 200
    // {"response": {"time": 1632358295}, "stat": "OK"


    CkHttp_Dispose(http);

    }