Sample code for 30+ languages & platforms
Unicode C

OneLogin OIDC - Get Discovery Document (OpenID Connect)

See more OneLogin OIDC Examples

Downloads the OpenID Connect self-discovery document for a OneLogin OIDC enabled app.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttpW http;
    HCkHttpResponseW resp;
    HCkJsonObjectW jsonResponse;
    const wchar_t *authorization_endpoint;
    BOOL claims_parameter_supported;
    const wchar_t *issuer;
    const wchar_t *jwks_uri;
    BOOL request_parameter_supported;
    BOOL request_uri_parameter_supported;
    const wchar_t *token_endpoint;
    const wchar_t *userinfo_endpoint;
    const wchar_t *introspection_endpoint;
    const wchar_t *revocation_endpoint;
    int i;
    int count_i;
    const wchar_t *strVal;

    success = FALSE;

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

    http = CkHttpW_Create();

    CkHttpW_putAccept(http,L"application/json");

    resp = CkHttpResponseW_Create();
    success = CkHttpW_HttpNoBody(http,L"GET",L"https://<account>.onelogin.com/oidc/.well-known/openid-configuration",resp);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkHttpResponseW_Dispose(resp);
        return;
    }

    wprintf(L"Response Status Code: %d\n",CkHttpResponseW_getStatusCode(resp));

    jsonResponse = CkJsonObjectW_Create();
    CkJsonObjectW_Load(jsonResponse,CkHttpResponseW_bodyStr(resp));
    CkJsonObjectW_putEmitCompact(jsonResponse,FALSE);
    wprintf(L"%s\n",CkJsonObjectW_emit(jsonResponse));

    if (CkHttpResponseW_getStatusCode(resp) != 200) {
        wprintf(L"Failed.\n");
        CkHttpW_Dispose(http);
        CkHttpResponseW_Dispose(resp);
        CkJsonObjectW_Dispose(jsonResponse);
        return;
    }

    // Sample output...
    // (See the parsing code below..)
    // 
    // Use the this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    // {
    //   "acr_values_supported": [
    //     "onelogin:nist:level:1:re-auth"
    //   ],
    //   "authorization_endpoint": "https://chilkat-dev.onelogin.com/oidc/auth",
    //   "claims_parameter_supported": true,
    //   "claims_supported": [
    //     "acr",
    //     "auth_time",
    //     "company",
    //     "custom_fields",
    //     "department",
    //     "email",
    //     "family_name",
    //     "given_name",
    //     "groups",
    //     "iss",
    //     "locale_code",
    //     "name",
    //     "params",
    //     "phone_number",
    //     "preferred_username",
    //     "sid",
    //     "sub",
    //     "title",
    //     "updated_at"
    //   ],
    //   "grant_types_supported": [
    //     "authorization_code",
    //     "implicit",
    //     "refresh_token",
    //     "client_credentials",
    //     "password"
    //   ],
    //   "id_token_signing_alg_values_supported": [
    //     "RS256"
    //   ],
    //   "issuer": "https://openid-connect.onelogin.com/oidc",
    //   "jwks_uri": "https://chilkat-dev.onelogin.com/oidc/certs",
    //   "request_parameter_supported": false,
    //   "request_uri_parameter_supported": false,
    //   "response_modes_supported": [
    //     "form_post",
    //     "fragment",
    //     "query"
    //   ],
    //   "response_types_supported": [
    //     "code",
    //     "id_token token",
    //     "id_token"
    //   ],
    //   "scopes_supported": [
    //     "openid",
    //     "name",
    //     "profile",
    //     "groups",
    //     "email",
    //     "params",
    //     "phone"
    //   ],
    //   "subject_types_supported": [
    //     "public"
    //   ],
    //   "token_endpoint": "https://chilkat-dev.onelogin.com/oidc/token",
    //   "token_endpoint_auth_methods_supported": [
    //     "client_secret_basic",
    //     "client_secret_post",
    //     "none"
    //   ],
    //   "userinfo_endpoint": "https://chilkat-dev.onelogin.com/oidc/me",
    //   "userinfo_signing_alg_values_supported": [
    //   ],
    //   "code_challenge_methods_supported": [
    //     "S256"
    //   ],
    //   "introspection_endpoint": "https://chilkat-dev.onelogin.com/oidc/token/introspection",
    //   "introspection_endpoint_auth_methods_supported": [
    //     "client_secret_basic",
    //     "client_secret_post",
    //     "none"
    //   ],
    //   "revocation_endpoint": "https://chilkat-dev.onelogin.com/oidc/token/revocation",
    //   "revocation_endpoint_auth_methods_supported": [
    //     "client_secret_basic",
    //     "client_secret_post",
    //     "none"
    //   ],
    //   "claim_types_supported": [
    //     "normal"
    //   ]
    // }
    // 

    authorization_endpoint = CkJsonObjectW_stringOf(jsonResponse,L"authorization_endpoint");
    claims_parameter_supported = CkJsonObjectW_BoolOf(jsonResponse,L"claims_parameter_supported");
    issuer = CkJsonObjectW_stringOf(jsonResponse,L"issuer");
    jwks_uri = CkJsonObjectW_stringOf(jsonResponse,L"jwks_uri");
    request_parameter_supported = CkJsonObjectW_BoolOf(jsonResponse,L"request_parameter_supported");
    request_uri_parameter_supported = CkJsonObjectW_BoolOf(jsonResponse,L"request_uri_parameter_supported");
    token_endpoint = CkJsonObjectW_stringOf(jsonResponse,L"token_endpoint");
    userinfo_endpoint = CkJsonObjectW_stringOf(jsonResponse,L"userinfo_endpoint");
    introspection_endpoint = CkJsonObjectW_stringOf(jsonResponse,L"introspection_endpoint");
    revocation_endpoint = CkJsonObjectW_stringOf(jsonResponse,L"revocation_endpoint");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"acr_values_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"acr_values_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"claims_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"claims_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"grant_types_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"grant_types_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"id_token_signing_alg_values_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"id_token_signing_alg_values_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"response_modes_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"response_modes_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"response_types_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"response_types_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"scopes_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"scopes_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"subject_types_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"subject_types_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"token_endpoint_auth_methods_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"token_endpoint_auth_methods_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"userinfo_signing_alg_values_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"code_challenge_methods_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"code_challenge_methods_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"introspection_endpoint_auth_methods_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"introspection_endpoint_auth_methods_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"revocation_endpoint_auth_methods_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"revocation_endpoint_auth_methods_supported[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"claim_types_supported");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        strVal = CkJsonObjectW_stringOf(jsonResponse,L"claim_types_supported[i]");
        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkHttpResponseW_Dispose(resp);
    CkJsonObjectW_Dispose(jsonResponse);

    }