C
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 C Downloads
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
HCkHttpResponse resp;
HCkJsonObject jsonResponse;
const char *authorization_endpoint;
BOOL claims_parameter_supported;
const char *issuer;
const char *jwks_uri;
BOOL request_parameter_supported;
BOOL request_uri_parameter_supported;
const char *token_endpoint;
const char *userinfo_endpoint;
const char *introspection_endpoint;
const char *revocation_endpoint;
int i;
int count_i;
const char *strVal;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
CkHttp_putAccept(http,"application/json");
resp = CkHttpResponse_Create();
success = CkHttp_HttpNoBody(http,"GET","https://<account>.onelogin.com/oidc/.well-known/openid-configuration",resp);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
return;
}
printf("Response Status Code: %d\n",CkHttpResponse_getStatusCode(resp));
jsonResponse = CkJsonObject_Create();
CkJsonObject_Load(jsonResponse,CkHttpResponse_bodyStr(resp));
CkJsonObject_putEmitCompact(jsonResponse,FALSE);
printf("%s\n",CkJsonObject_emit(jsonResponse));
if (CkHttpResponse_getStatusCode(resp) != 200) {
printf("Failed.\n");
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
CkJsonObject_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 = CkJsonObject_stringOf(jsonResponse,"authorization_endpoint");
claims_parameter_supported = CkJsonObject_BoolOf(jsonResponse,"claims_parameter_supported");
issuer = CkJsonObject_stringOf(jsonResponse,"issuer");
jwks_uri = CkJsonObject_stringOf(jsonResponse,"jwks_uri");
request_parameter_supported = CkJsonObject_BoolOf(jsonResponse,"request_parameter_supported");
request_uri_parameter_supported = CkJsonObject_BoolOf(jsonResponse,"request_uri_parameter_supported");
token_endpoint = CkJsonObject_stringOf(jsonResponse,"token_endpoint");
userinfo_endpoint = CkJsonObject_stringOf(jsonResponse,"userinfo_endpoint");
introspection_endpoint = CkJsonObject_stringOf(jsonResponse,"introspection_endpoint");
revocation_endpoint = CkJsonObject_stringOf(jsonResponse,"revocation_endpoint");
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"acr_values_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"acr_values_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"claims_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"claims_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"grant_types_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"grant_types_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"id_token_signing_alg_values_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"id_token_signing_alg_values_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"response_modes_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"response_modes_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"response_types_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"response_types_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"scopes_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"scopes_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"subject_types_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"subject_types_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"token_endpoint_auth_methods_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"token_endpoint_auth_methods_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"userinfo_signing_alg_values_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"code_challenge_methods_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"code_challenge_methods_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"introspection_endpoint_auth_methods_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"introspection_endpoint_auth_methods_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"revocation_endpoint_auth_methods_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"revocation_endpoint_auth_methods_supported[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"claim_types_supported");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
strVal = CkJsonObject_stringOf(jsonResponse,"claim_types_supported[i]");
i = i + 1;
}
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
CkJsonObject_Dispose(jsonResponse);
}