Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C++) OneLogin OIDC - Get Discovery Document (OpenID Connect)Downloads the OpenID Connect self-discovery document for a OneLogin OIDC enabled app. For more information, see https://developers.onelogin.com/openid-connect/connect-to-onelogin
#include <CkHttpW.h> #include <CkHttpResponseW.h> #include <CkJsonObjectW.h> void ChilkatSample(void) { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpW http; http.put_Accept(L"application/json"); CkHttpResponseW *resp = http.QuickRequest(L"GET",L"https://<account>.onelogin.com/oidc/.well-known/openid-configuration"); if (http.get_LastMethodSuccess() != true) { wprintf(L"%s\n",http.lastErrorText()); return; } wprintf(L"Response Status Code: %d\n",resp->get_StatusCode()); CkJsonObjectW jsonResponse; jsonResponse.Load(resp->bodyStr()); jsonResponse.put_EmitCompact(false); wprintf(L"%s\n",jsonResponse.emit()); if (resp->get_StatusCode() != 200) { wprintf(L"Failed.\n"); delete resp; return; } delete resp; // 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" // ] // } // const wchar_t *authorization_endpoint = 0; bool claims_parameter_supported; const wchar_t *issuer = 0; const wchar_t *jwks_uri = 0; bool request_parameter_supported; bool request_uri_parameter_supported; const wchar_t *token_endpoint = 0; const wchar_t *userinfo_endpoint = 0; const wchar_t *introspection_endpoint = 0; const wchar_t *revocation_endpoint = 0; int i; int count_i; const wchar_t *strVal = 0; authorization_endpoint = jsonResponse.stringOf(L"authorization_endpoint"); claims_parameter_supported = jsonResponse.BoolOf(L"claims_parameter_supported"); issuer = jsonResponse.stringOf(L"issuer"); jwks_uri = jsonResponse.stringOf(L"jwks_uri"); request_parameter_supported = jsonResponse.BoolOf(L"request_parameter_supported"); request_uri_parameter_supported = jsonResponse.BoolOf(L"request_uri_parameter_supported"); token_endpoint = jsonResponse.stringOf(L"token_endpoint"); userinfo_endpoint = jsonResponse.stringOf(L"userinfo_endpoint"); introspection_endpoint = jsonResponse.stringOf(L"introspection_endpoint"); revocation_endpoint = jsonResponse.stringOf(L"revocation_endpoint"); i = 0; count_i = jsonResponse.SizeOfArray(L"acr_values_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"acr_values_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"claims_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"claims_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"grant_types_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"grant_types_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"id_token_signing_alg_values_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"id_token_signing_alg_values_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"response_modes_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"response_modes_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"response_types_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"response_types_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"scopes_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"scopes_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"subject_types_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"subject_types_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"token_endpoint_auth_methods_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"token_endpoint_auth_methods_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"userinfo_signing_alg_values_supported"); while (i < count_i) { jsonResponse.put_I(i); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"code_challenge_methods_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"code_challenge_methods_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"introspection_endpoint_auth_methods_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"introspection_endpoint_auth_methods_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"revocation_endpoint_auth_methods_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"revocation_endpoint_auth_methods_supported[i]"); i = i + 1; } i = 0; count_i = jsonResponse.SizeOfArray(L"claim_types_supported"); while (i < count_i) { jsonResponse.put_I(i); strVal = jsonResponse.stringOf(L"claim_types_supported[i]"); i = i + 1; } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.