Unicode C
Unicode C
Amazon Cognito - Describe User Pool
See more Amazon Cognito Examples
Returns the configuration information and metadata of the specified user pool.Chilkat Unicode C Downloads
#include <C_CkRestW.h>
#include <C_CkAuthAwsW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkRestW rest;
HCkAuthAwsW authAws;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *Name;
int Priority;
const wchar_t *strVal;
const wchar_t *AttributeDataType;
BOOL DeveloperOnlyAttribute;
BOOL Mutable;
BOOL Required;
const wchar_t *StringAttributeConstraintsMaxLength;
const wchar_t *StringAttributeConstraintsMinLength;
const wchar_t *NumberAttributeConstraintsMinValue;
BOOL UserPoolAdminCreateUserConfigAllowAdminCreateUserOnly;
const wchar_t *UserPoolAdminCreateUserConfigInviteMessageTemplateEmailMessage;
const wchar_t *UserPoolAdminCreateUserConfigInviteMessageTemplateEmailSubject;
const wchar_t *UserPoolAdminCreateUserConfigInviteMessageTemplateSMSMessage;
int UserPoolAdminCreateUserConfigUnusedAccountValidityDays;
const wchar_t *UserPoolArn;
const wchar_t *UserPoolCreationDate;
const wchar_t *UserPoolEmailConfigurationEmailSendingAccount;
const wchar_t *UserPoolEmailConfigurationFrom;
const wchar_t *UserPoolEmailConfigurationReplyToEmailAddress;
const wchar_t *UserPoolEmailConfigurationSourceArn;
const wchar_t *UserPoolEmailVerificationMessage;
const wchar_t *UserPoolEmailVerificationSubject;
int UserPoolEstimatedNumberOfUsers;
const wchar_t *UserPoolId;
const wchar_t *UserPoolLastModifiedDate;
const wchar_t *UserPoolMfaConfiguration;
const wchar_t *UserPoolName;
int UserPoolPoliciesPasswordPolicyMinimumLength;
BOOL UserPoolPoliciesPasswordPolicyRequireLowercase;
BOOL UserPoolPoliciesPasswordPolicyRequireNumbers;
BOOL UserPoolPoliciesPasswordPolicyRequireSymbols;
BOOL UserPoolPoliciesPasswordPolicyRequireUppercase;
int UserPoolPoliciesPasswordPolicyTemporaryPasswordValidityDays;
const wchar_t *UserPoolSmsAuthenticationMessage;
const wchar_t *UserPoolSmsConfigurationExternalId;
const wchar_t *UserPoolSmsConfigurationSnsCallerArn;
const wchar_t *UserPoolSmsVerificationMessage;
const wchar_t *UserPoolUserPoolTagsSampleUserPoolTag;
BOOL UserPoolUsernameConfigurationCaseSensitive;
const wchar_t *UserPoolVerificationMessageTemplateDefaultEmailOption;
const wchar_t *UserPoolVerificationMessageTemplateEmailMessage;
const wchar_t *UserPoolVerificationMessageTemplateEmailSubject;
const wchar_t *UserPoolVerificationMessageTemplateSmsMessage;
int i;
int count_i;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest = CkRestW_Create();
authAws = CkAuthAwsW_Create();
CkAuthAwsW_putAccessKey(authAws,L"AWS_ACCESS_KEY");
CkAuthAwsW_putSecretKey(authAws,L"AWS_SECRET_KEY");
// Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
CkAuthAwsW_putRegion(authAws,L"us-west-2");
CkAuthAwsW_putServiceName(authAws,L"cognito-idp");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRestW_SetAuthAws(rest,authAws);
// URL: https://cognito-idp.us-west-2.amazonaws.com/
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
// Use the same region as specified above.
success = CkRestW_Connect(rest,L"cognito-idp.us-west-2.amazonaws.com",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
return;
}
// Note: The above code does not need to be repeatedly called for each REST request.
// The rest object can be setup once, and then many requests can be sent. Chilkat will automatically
// reconnect within a FullRequest* method as needed. It is only the very first connection that is explicitly
// made via the Connect method.
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"UserPoolId",L"us-west-2_yt6WzO3SA");
CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.0");
CkRestW_AddHeader(rest,L"X-Amz-Target",L"AWSCognitoIdentityProviderService.DescribeUserPool");
CkRestW_AddHeader(rest,L"Accept-Encoding",L"identity");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"POST",L"/",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
CkJsonObjectW_putEmitCompact(jsonResponse,FALSE);
wprintf(L"%s\n",CkJsonObjectW_emit(jsonResponse));
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
// {
// "UserPool": {
// "AccountRecoverySetting": {
// "RecoveryMechanisms": [
// {
// "Name": "verified_phone_number",
// "Priority": 1
// },
// {
// "Name": "verified_email",
// "Priority": 2
// }
// ]
// },
// "AdminCreateUserConfig": {
// "AllowAdminCreateUserOnly": false,
// "InviteMessageTemplate": {
// "EmailMessage": "Your username is {username} and temporary password is {####}. ",
// "EmailSubject": "Your temporary password",
// "SMSMessage": "Your username is {username} and temporary password is {####}. "
// },
// "UnusedAccountValidityDays": 7
// },
// "Arn": "arn:aws:cognito-idp:us-west-2:954491834127:userpool/us-west-2_yt6WzO3SA",
// "AutoVerifiedAttributes": [
// "email",
// "phone_number"
// ],
// "CreationDate": 1.636388909817E9,
// "EmailConfiguration": {
// "EmailSendingAccount": "DEVELOPER",
// "From": "admin@chilkatsoft.com",
// "ReplyToEmailAddress": "admin@chilkatsoft.com",
// "SourceArn": "arn:aws:ses:us-west-2:954491834127:identity/admin@chilkatsoft.com"
// },
// "EmailVerificationMessage": "Your verification code is {####}. ",
// "EmailVerificationSubject": "Your verification code",
// "EstimatedNumberOfUsers": 0,
// "Id": "us-west-2_yt6WzO3SA",
// "LambdaConfig": {},
// "LastModifiedDate": 1.636388910377E9,
// "MfaConfiguration": "ON",
// "Name": "chilkat",
// "Policies": {
// "PasswordPolicy": {
// "MinimumLength": 8,
// "RequireLowercase": true,
// "RequireNumbers": true,
// "RequireSymbols": true,
// "RequireUppercase": true,
// "TemporaryPasswordValidityDays": 7
// }
// },
// "SchemaAttributes": [
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": false,
// "Name": "sub",
// "Required": true,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "1"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "name",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "given_name",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "family_name",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "middle_name",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "nickname",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "preferred_username",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "profile",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "picture",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "website",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "email",
// "Required": true,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "Boolean",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "email_verified",
// "Required": false
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "gender",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "birthdate",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "10",
// "MinLength": "10"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "zoneinfo",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "locale",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "phone_number",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "Boolean",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "phone_number_verified",
// "Required": false
// },
// {
// "AttributeDataType": "String",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "address",
// "Required": false,
// "StringAttributeConstraints": {
// "MaxLength": "2048",
// "MinLength": "0"
// }
// },
// {
// "AttributeDataType": "Number",
// "DeveloperOnlyAttribute": false,
// "Mutable": true,
// "Name": "updated_at",
// "NumberAttributeConstraints": {
// "MinValue": "0"
// },
// "Required": false
// }
// ],
// "SmsAuthenticationMessage": "Your verification code is {####}. ",
// "SmsConfiguration": {
// "ExternalId": "94b17737-216b-4cf7-a29e-17e990e91300",
// "SnsCallerArn": "arn:aws:iam::954491834127:role/service-role/chilkat-SMS-Role"
// },
// "SmsVerificationMessage": "Your verification code is {####}. ",
// "UserPoolTags": {
// "sampleUserPoolTag": "test"
// },
// "UsernameConfiguration": {
// "CaseSensitive": false
// },
// "VerificationMessageTemplate": {
// "DefaultEmailOption": "CONFIRM_WITH_CODE",
// "EmailMessage": "Your verification code is {####}. ",
// "EmailSubject": "Your verification code",
// "SmsMessage": "Your verification code is {####}. "
// }
// }
// }
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
UserPoolAdminCreateUserConfigAllowAdminCreateUserOnly = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.AdminCreateUserConfig.AllowAdminCreateUserOnly");
UserPoolAdminCreateUserConfigInviteMessageTemplateEmailMessage = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.AdminCreateUserConfig.InviteMessageTemplate.EmailMessage");
UserPoolAdminCreateUserConfigInviteMessageTemplateEmailSubject = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.AdminCreateUserConfig.InviteMessageTemplate.EmailSubject");
UserPoolAdminCreateUserConfigInviteMessageTemplateSMSMessage = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.AdminCreateUserConfig.InviteMessageTemplate.SMSMessage");
UserPoolAdminCreateUserConfigUnusedAccountValidityDays = CkJsonObjectW_IntOf(jsonResponse,L"UserPool.AdminCreateUserConfig.UnusedAccountValidityDays");
UserPoolArn = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.Arn");
UserPoolCreationDate = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.CreationDate");
UserPoolEmailConfigurationEmailSendingAccount = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.EmailConfiguration.EmailSendingAccount");
UserPoolEmailConfigurationFrom = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.EmailConfiguration.From");
UserPoolEmailConfigurationReplyToEmailAddress = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.EmailConfiguration.ReplyToEmailAddress");
UserPoolEmailConfigurationSourceArn = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.EmailConfiguration.SourceArn");
UserPoolEmailVerificationMessage = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.EmailVerificationMessage");
UserPoolEmailVerificationSubject = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.EmailVerificationSubject");
UserPoolEstimatedNumberOfUsers = CkJsonObjectW_IntOf(jsonResponse,L"UserPool.EstimatedNumberOfUsers");
UserPoolId = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.Id");
UserPoolLastModifiedDate = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.LastModifiedDate");
UserPoolMfaConfiguration = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.MfaConfiguration");
UserPoolName = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.Name");
UserPoolPoliciesPasswordPolicyMinimumLength = CkJsonObjectW_IntOf(jsonResponse,L"UserPool.Policies.PasswordPolicy.MinimumLength");
UserPoolPoliciesPasswordPolicyRequireLowercase = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.Policies.PasswordPolicy.RequireLowercase");
UserPoolPoliciesPasswordPolicyRequireNumbers = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.Policies.PasswordPolicy.RequireNumbers");
UserPoolPoliciesPasswordPolicyRequireSymbols = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.Policies.PasswordPolicy.RequireSymbols");
UserPoolPoliciesPasswordPolicyRequireUppercase = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.Policies.PasswordPolicy.RequireUppercase");
UserPoolPoliciesPasswordPolicyTemporaryPasswordValidityDays = CkJsonObjectW_IntOf(jsonResponse,L"UserPool.Policies.PasswordPolicy.TemporaryPasswordValidityDays");
UserPoolSmsAuthenticationMessage = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SmsAuthenticationMessage");
UserPoolSmsConfigurationExternalId = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SmsConfiguration.ExternalId");
UserPoolSmsConfigurationSnsCallerArn = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SmsConfiguration.SnsCallerArn");
UserPoolSmsVerificationMessage = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SmsVerificationMessage");
UserPoolUserPoolTagsSampleUserPoolTag = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.UserPoolTags.sampleUserPoolTag");
UserPoolUsernameConfigurationCaseSensitive = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.UsernameConfiguration.CaseSensitive");
UserPoolVerificationMessageTemplateDefaultEmailOption = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.VerificationMessageTemplate.DefaultEmailOption");
UserPoolVerificationMessageTemplateEmailMessage = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.VerificationMessageTemplate.EmailMessage");
UserPoolVerificationMessageTemplateEmailSubject = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.VerificationMessageTemplate.EmailSubject");
UserPoolVerificationMessageTemplateSmsMessage = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.VerificationMessageTemplate.SmsMessage");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"UserPool.AccountRecoverySetting.RecoveryMechanisms");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
Name = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.AccountRecoverySetting.RecoveryMechanisms[i].Name");
Priority = CkJsonObjectW_IntOf(jsonResponse,L"UserPool.AccountRecoverySetting.RecoveryMechanisms[i].Priority");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"UserPool.AutoVerifiedAttributes");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
strVal = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.AutoVerifiedAttributes[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"UserPool.SchemaAttributes");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
AttributeDataType = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SchemaAttributes[i].AttributeDataType");
DeveloperOnlyAttribute = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.SchemaAttributes[i].DeveloperOnlyAttribute");
Mutable = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.SchemaAttributes[i].Mutable");
Name = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SchemaAttributes[i].Name");
Required = CkJsonObjectW_BoolOf(jsonResponse,L"UserPool.SchemaAttributes[i].Required");
StringAttributeConstraintsMaxLength = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SchemaAttributes[i].StringAttributeConstraints.MaxLength");
StringAttributeConstraintsMinLength = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SchemaAttributes[i].StringAttributeConstraints.MinLength");
NumberAttributeConstraintsMinValue = CkJsonObjectW_stringOf(jsonResponse,L"UserPool.SchemaAttributes[i].NumberAttributeConstraints.MinValue");
i = i + 1;
}
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}