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) Amazon Cognito - Create User PoolSee more Amazon Cognito ExamplesCreates a new Amazon Cognito user pool and sets the password policy for the pool. For more information, see https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPool.html
#include <C_CkRestW.h> #include <C_CkAuthAwsW.h> #include <C_CkJsonObjectW.h> #include <C_CkStringBuilderW.h> void ChilkatSample(void) { HCkRestW rest; BOOL success; HCkAuthAwsW authAws; BOOL bTls; int port; BOOL bAutoReconnect; HCkJsonObjectW json; HCkStringBuilderW sbRequestBody; HCkStringBuilderW sbResponseBody; int respStatusCode; HCkJsonObjectW jsonResponse; // 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. // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // This example wil demonstrate creating a pool with many options specified. // The only required JSON member is "PoolName". // { // "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 {####}. " // }, // "TemporaryPasswordValidityDays": 7 // }, // "AutoVerifiedAttributes": [ // "email", // "phone_number" // ], // "EmailConfiguration": { // "EmailSendingAccount": "DEVELOPER", // "From": "joe@example.com", // "ReplyToEmailAddress": "joe@example.com", // "SourceArn": "arn:aws:ses:us-west-2:954491834127:identity/joe@example.com" // }, // "EmailVerificationMessage": "Your verification code is {####}. ", // "EmailVerificationSubject": "Your verification code", // "LambdaConfig": {}, // "MfaConfiguration": "OFF", // "PoolName": "MyTestPool", // "Policies": { // "PasswordPolicy": { // "MinimumLength": 8, // "RequireLowercase": true, // "RequireNumbers": true, // "RequireSymbols": true, // "RequireUppercase": true, // "TemporaryPasswordValidityDays": 7 // } // }, // "Schema": [ // { // "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": "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 {####}. ", // "UsernameConfiguration": { // "CaseSensitive": false // }, // "VerificationMessageTemplate": { // "DefaultEmailOption": "CONFIRM_WITH_CODE", // "EmailMessage": "Your verification code is {####}. ", // "EmailSubject": "Your verification code", // "SmsMessage": "Your verification code is {####}. " // } // } // json = CkJsonObjectW_Create(); CkJsonObjectW_UpdateString(json,L"AccountRecoverySetting.RecoveryMechanisms[0].Name",L"verified_phone_number"); CkJsonObjectW_UpdateInt(json,L"AccountRecoverySetting.RecoveryMechanisms[0].Priority",1); CkJsonObjectW_UpdateString(json,L"AccountRecoverySetting.RecoveryMechanisms[1].Name",L"verified_email"); CkJsonObjectW_UpdateInt(json,L"AccountRecoverySetting.RecoveryMechanisms[1].Priority",2); CkJsonObjectW_UpdateBool(json,L"AdminCreateUserConfig.AllowAdminCreateUserOnly",FALSE); CkJsonObjectW_UpdateString(json,L"AdminCreateUserConfig.InviteMessageTemplate.EmailMessage",L"Your username is {username} and temporary password is {####}. "); CkJsonObjectW_UpdateString(json,L"AdminCreateUserConfig.InviteMessageTemplate.EmailSubject",L"Your temporary password"); CkJsonObjectW_UpdateString(json,L"AdminCreateUserConfig.InviteMessageTemplate.SMSMessage",L"Your username is {username} and temporary password is {####}. "); CkJsonObjectW_UpdateInt(json,L"AdminCreateUserConfig.TemporaryPasswordValidityDays",7); CkJsonObjectW_UpdateString(json,L"AutoVerifiedAttributes[0]",L"email"); CkJsonObjectW_UpdateString(json,L"AutoVerifiedAttributes[1]",L"phone_number"); CkJsonObjectW_UpdateString(json,L"EmailConfiguration.EmailSendingAccount",L"DEVELOPER"); CkJsonObjectW_UpdateString(json,L"EmailConfiguration.From",L"joe@example.com"); CkJsonObjectW_UpdateString(json,L"EmailConfiguration.ReplyToEmailAddress",L"joe@example.com"); CkJsonObjectW_UpdateString(json,L"EmailConfiguration.SourceArn",L"arn:aws:ses:us-west-2:954491834127:identity/joe@example.com"); CkJsonObjectW_UpdateString(json,L"EmailVerificationMessage",L"Your verification code is {####}. "); CkJsonObjectW_UpdateString(json,L"EmailVerificationSubject",L"Your verification code"); CkJsonObjectW_UpdateNewObject(json,L"LambdaConfig"); CkJsonObjectW_UpdateString(json,L"MfaConfiguration",L"OFF"); CkJsonObjectW_UpdateString(json,L"PoolName",L"MyTestPool"); CkJsonObjectW_UpdateInt(json,L"Policies.PasswordPolicy.MinimumLength",8); CkJsonObjectW_UpdateBool(json,L"Policies.PasswordPolicy.RequireLowercase",TRUE); CkJsonObjectW_UpdateBool(json,L"Policies.PasswordPolicy.RequireNumbers",TRUE); CkJsonObjectW_UpdateBool(json,L"Policies.PasswordPolicy.RequireSymbols",TRUE); CkJsonObjectW_UpdateBool(json,L"Policies.PasswordPolicy.RequireUppercase",TRUE); CkJsonObjectW_UpdateInt(json,L"Policies.PasswordPolicy.TemporaryPasswordValidityDays",7); CkJsonObjectW_UpdateString(json,L"Schema[0].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[0].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[0].Mutable",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[0].Name",L"sub"); CkJsonObjectW_UpdateBool(json,L"Schema[0].Required",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[0].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[0].StringAttributeConstraints.MinLength",L"1"); CkJsonObjectW_UpdateString(json,L"Schema[1].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[1].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[1].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[1].Name",L"name"); CkJsonObjectW_UpdateBool(json,L"Schema[1].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[1].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[1].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[2].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[2].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[2].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[2].Name",L"given_name"); CkJsonObjectW_UpdateBool(json,L"Schema[2].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[2].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[2].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[3].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[3].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[3].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[3].Name",L"family_name"); CkJsonObjectW_UpdateBool(json,L"Schema[3].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[3].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[3].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[4].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[4].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[4].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[4].Name",L"middle_name"); CkJsonObjectW_UpdateBool(json,L"Schema[4].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[4].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[4].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[5].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[5].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[5].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[5].Name",L"nickname"); CkJsonObjectW_UpdateBool(json,L"Schema[5].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[5].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[5].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[6].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[6].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[6].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[6].Name",L"preferred_username"); CkJsonObjectW_UpdateBool(json,L"Schema[6].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[6].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[6].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[7].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[7].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[7].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[7].Name",L"profile"); CkJsonObjectW_UpdateBool(json,L"Schema[7].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[7].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[7].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[8].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[8].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[8].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[8].Name",L"picture"); CkJsonObjectW_UpdateBool(json,L"Schema[8].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[8].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[8].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[9].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[9].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[9].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[9].Name",L"website"); CkJsonObjectW_UpdateBool(json,L"Schema[9].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[9].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[9].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[10].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[10].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[10].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[10].Name",L"email"); CkJsonObjectW_UpdateBool(json,L"Schema[10].Required",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[10].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[10].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[11].AttributeDataType",L"Boolean"); CkJsonObjectW_UpdateBool(json,L"Schema[11].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[11].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[11].Name",L"email_verified"); CkJsonObjectW_UpdateBool(json,L"Schema[11].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[12].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[12].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[12].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[12].Name",L"gender"); CkJsonObjectW_UpdateBool(json,L"Schema[12].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[12].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[12].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[13].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[13].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[13].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[13].Name",L"birthdate"); CkJsonObjectW_UpdateBool(json,L"Schema[13].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[13].StringAttributeConstraints.MaxLength",L"10"); CkJsonObjectW_UpdateString(json,L"Schema[13].StringAttributeConstraints.MinLength",L"10"); CkJsonObjectW_UpdateString(json,L"Schema[14].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[14].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[14].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[14].Name",L"zoneinfo"); CkJsonObjectW_UpdateBool(json,L"Schema[14].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[14].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[14].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[15].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[15].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[15].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[15].Name",L"locale"); CkJsonObjectW_UpdateBool(json,L"Schema[15].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[15].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[15].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[16].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[16].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[16].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[16].Name",L"phone_number"); CkJsonObjectW_UpdateBool(json,L"Schema[16].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[16].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[16].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[17].AttributeDataType",L"String"); CkJsonObjectW_UpdateBool(json,L"Schema[17].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[17].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[17].Name",L"address"); CkJsonObjectW_UpdateBool(json,L"Schema[17].Required",FALSE); CkJsonObjectW_UpdateString(json,L"Schema[17].StringAttributeConstraints.MaxLength",L"2048"); CkJsonObjectW_UpdateString(json,L"Schema[17].StringAttributeConstraints.MinLength",L"0"); CkJsonObjectW_UpdateString(json,L"Schema[18].AttributeDataType",L"Number"); CkJsonObjectW_UpdateBool(json,L"Schema[18].DeveloperOnlyAttribute",FALSE); CkJsonObjectW_UpdateBool(json,L"Schema[18].Mutable",TRUE); CkJsonObjectW_UpdateString(json,L"Schema[18].Name",L"updated_at"); CkJsonObjectW_UpdateString(json,L"Schema[18].NumberAttributeConstraints.MinValue",L"0"); CkJsonObjectW_UpdateBool(json,L"Schema[18].Required",FALSE); CkJsonObjectW_UpdateString(json,L"SmsAuthenticationMessage",L"Your verification code is {####}. "); // Use your own value here: CkJsonObjectW_UpdateString(json,L"SmsConfiguration.ExternalId",L"94b17737-216b-4cf7-a29e-17e990e91300"); CkJsonObjectW_UpdateString(json,L"SmsConfiguration.SnsCallerArn",L"arn:aws:iam::954491834127:role/service-role/chilkat-SMS-Role"); CkJsonObjectW_UpdateString(json,L"SmsVerificationMessage",L"Your verification code is {####}. "); CkJsonObjectW_UpdateBool(json,L"UsernameConfiguration.CaseSensitive",FALSE); CkJsonObjectW_UpdateString(json,L"VerificationMessageTemplate.DefaultEmailOption",L"CONFIRM_WITH_CODE"); CkJsonObjectW_UpdateString(json,L"VerificationMessageTemplate.EmailMessage",L"Your verification code is {####}. "); CkJsonObjectW_UpdateString(json,L"VerificationMessageTemplate.EmailSubject",L"Your verification code"); CkJsonObjectW_UpdateString(json,L"VerificationMessageTemplate.SmsMessage",L"Your verification code is {####}. "); CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.0"); CkRestW_AddHeader(rest,L"X-Amz-Target",L"AWSCognitoIdentityProviderService.CreateUserPool"); 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)); // The response is similar to the response at Cognito Describe User Pool CkRestW_Dispose(rest); CkAuthAwsW_Dispose(authAws); CkJsonObjectW_Dispose(json); CkStringBuilderW_Dispose(sbRequestBody); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jsonResponse); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.