Files
c/kubernetes/api/WellKnownAPI.c

75 lines
2.1 KiB
C
Raw Permalink Normal View History

2021-09-14 21:52:06 +08:00
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "WellKnownAPI.h"
#define MAX_NUMBER_LENGTH 16
#define MAX_BUFFER_LENGTH 4096
// get service account issuer OpenID configuration, also known as the 'OIDC discovery doc'
//
char*
WellKnownAPI_getServiceAccountIssuerOpenIDConfiguration(apiClient_t *apiClient)
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
list_t *localVarFormParameters = NULL;
list_t *localVarHeaderType = list_createList();
2021-09-14 21:52:06 +08:00
list_t *localVarContentType = NULL;
char *localVarBodyParameters = NULL;
size_t localVarBodyLength = 0;
// clear the error code from the previous api call
apiClient->response_code = 0;
2021-09-14 21:52:06 +08:00
// create the path
char *localVarPath = strdup("/.well-known/openid-configuration");
2021-09-14 21:52:06 +08:00
list_addElement(localVarHeaderType,"application/json"); //produces
apiClient_invoke(apiClient,
localVarPath,
localVarQueryParameters,
localVarHeaderParameters,
localVarFormParameters,
localVarHeaderType,
localVarContentType,
localVarBodyParameters,
localVarBodyLength,
2021-09-14 21:52:06 +08:00
"GET");
// uncomment below to debug the error response
//if (apiClient->response_code == 200) {
// printf("%s\n","OK");
//}
// uncomment below to debug the error response
//if (apiClient->response_code == 401) {
// printf("%s\n","Unauthorized");
//}
//primitive return type simple string
char* elementToReturn = NULL;
if(apiClient->response_code >= 200 && apiClient->response_code < 300)
elementToReturn = strdup((char*)apiClient->dataReceived);
2021-09-14 21:52:06 +08:00
if (apiClient->dataReceived) {
free(apiClient->dataReceived);
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
}
list_freeList(localVarHeaderType);
2021-09-14 21:52:06 +08:00
free(localVarPath);
return elementToReturn;
end:
free(localVarPath);
return NULL;
}