Xbase++
Xbase++
Amazon Cognito - Describe User Pool
See more Amazon Cognito Examples
Returns the configuration information and metadata of the specified user pool.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oRest
LOCAL oAuthAws
LOCAL nBTls
LOCAL nPort
LOCAL nBAutoReconnect
LOCAL oJson
LOCAL oSbRequestBody
LOCAL oSbResponseBody
LOCAL nRespStatusCode
LOCAL oJsonResponse
LOCAL cName
LOCAL nPriority
LOCAL cStrVal
LOCAL cAttributeDataType
LOCAL nDeveloperOnlyAttribute
LOCAL nMutable
LOCAL nRequired
LOCAL cStringAttributeConstraintsMaxLength
LOCAL cStringAttributeConstraintsMinLength
LOCAL cNumberAttributeConstraintsMinValue
LOCAL nUserPoolAdminCreateUserConfigAllowAdminCreateUserOnly
LOCAL cUserPoolAdminCreateUserConfigInviteMessageTemplateEmailMessage
LOCAL cUserPoolAdminCreateUserConfigInviteMessageTemplateEmailSubject
LOCAL cUserPoolAdminCreateUserConfigInviteMessageTemplateSMSMessage
LOCAL nUserPoolAdminCreateUserConfigUnusedAccountValidityDays
LOCAL cUserPoolArn
LOCAL cUserPoolCreationDate
LOCAL cUserPoolEmailConfigurationEmailSendingAccount
LOCAL cUserPoolEmailConfigurationFrom
LOCAL cUserPoolEmailConfigurationReplyToEmailAddress
LOCAL cUserPoolEmailConfigurationSourceArn
LOCAL cUserPoolEmailVerificationMessage
LOCAL cUserPoolEmailVerificationSubject
LOCAL nUserPoolEstimatedNumberOfUsers
LOCAL cUserPoolId
LOCAL cUserPoolLastModifiedDate
LOCAL cUserPoolMfaConfiguration
LOCAL cUserPoolName
LOCAL nUserPoolPoliciesPasswordPolicyMinimumLength
LOCAL nUserPoolPoliciesPasswordPolicyRequireLowercase
LOCAL nUserPoolPoliciesPasswordPolicyRequireNumbers
LOCAL nUserPoolPoliciesPasswordPolicyRequireSymbols
LOCAL nUserPoolPoliciesPasswordPolicyRequireUppercase
LOCAL nUserPoolPoliciesPasswordPolicyTemporaryPasswordValidityDays
LOCAL cUserPoolSmsAuthenticationMessage
LOCAL cUserPoolSmsConfigurationExternalId
LOCAL cUserPoolSmsConfigurationSnsCallerArn
LOCAL cUserPoolSmsVerificationMessage
LOCAL cUserPoolUserPoolTagsSampleUserPoolTag
LOCAL nUserPoolUsernameConfigurationCaseSensitive
LOCAL cUserPoolVerificationMessageTemplateDefaultEmailOption
LOCAL cUserPoolVerificationMessageTemplateEmailMessage
LOCAL cUserPoolVerificationMessageTemplateEmailSubject
LOCAL cUserPoolVerificationMessageTemplateSmsMessage
LOCAL i
LOCAL nCount_i
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oRest := CreateObject("Chilkat.Rest")
oAuthAws := CreateObject("Chilkat.AuthAws")
oAuthAws:AccessKey := "AWS_ACCESS_KEY"
oAuthAws:SecretKey := "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.)
oAuthAws:Region := "us-west-2"
oAuthAws:ServiceName := "cognito-idp"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
oRest:SetAuthAws(oAuthAws)
// URL: https://cognito-idp.us-west-2.amazonaws.com/
nBTls := 1
nPort := 443
nBAutoReconnect := 1
// Use the same region as specified above.
nSuccess := oRest:Connect("cognito-idp.us-west-2.amazonaws.com", nPort, nBTls, nBAutoReconnect)
IF (nSuccess != 1)
? "ConnectFailReason: " + Str(oRest:ConnectFailReason)
? oRest:LastErrorText
oRest:destroy()
oAuthAws:destroy()
RETURN
ENDIF
// 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.
oJson := CreateObject("Chilkat.JsonObject")
oJson:UpdateString("UserPoolId", "us-west-2_yt6WzO3SA")
oRest:AddHeader("Content-Type", "application/x-amz-json-1.0")
oRest:AddHeader("X-Amz-Target", "AWSCognitoIdentityProviderService.DescribeUserPool")
oRest:AddHeader("Accept-Encoding", "identity")
oSbRequestBody := CreateObject("Chilkat.StringBuilder")
oJson:EmitSb(oSbRequestBody)
oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oRest:FullRequestSb("POST", "/", oSbRequestBody, oSbResponseBody)
IF (nSuccess != 1)
? oRest:LastErrorText
oRest:destroy()
oAuthAws:destroy()
oJson:destroy()
oSbRequestBody:destroy()
oSbResponseBody:destroy()
RETURN
ENDIF
nRespStatusCode := oRest:ResponseStatusCode
? "response status code = " + Str(nRespStatusCode)
IF (nRespStatusCode != 200)
? "Response Status Code = " + Str(nRespStatusCode)
? "Response Header:"
? oRest:ResponseHeader
? "Response Body:"
? oSbResponseBody:GetAsString()
oRest:destroy()
oAuthAws:destroy()
oJson:destroy()
oSbRequestBody:destroy()
oSbResponseBody:destroy()
RETURN
ENDIF
oJsonResponse := CreateObject("Chilkat.JsonObject")
oJsonResponse:LoadSb(oSbResponseBody)
oJsonResponse:EmitCompact := 0
? oJsonResponse:Emit()
// 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 {####}. "
// }
// }
// }
nUserPoolAdminCreateUserConfigAllowAdminCreateUserOnly := oJsonResponse:BoolOf("UserPool.AdminCreateUserConfig.AllowAdminCreateUserOnly")
cUserPoolAdminCreateUserConfigInviteMessageTemplateEmailMessage := oJsonResponse:StringOf("UserPool.AdminCreateUserConfig.InviteMessageTemplate.EmailMessage")
cUserPoolAdminCreateUserConfigInviteMessageTemplateEmailSubject := oJsonResponse:StringOf("UserPool.AdminCreateUserConfig.InviteMessageTemplate.EmailSubject")
cUserPoolAdminCreateUserConfigInviteMessageTemplateSMSMessage := oJsonResponse:StringOf("UserPool.AdminCreateUserConfig.InviteMessageTemplate.SMSMessage")
nUserPoolAdminCreateUserConfigUnusedAccountValidityDays := oJsonResponse:IntOf("UserPool.AdminCreateUserConfig.UnusedAccountValidityDays")
cUserPoolArn := oJsonResponse:StringOf("UserPool.Arn")
cUserPoolCreationDate := oJsonResponse:StringOf("UserPool.CreationDate")
cUserPoolEmailConfigurationEmailSendingAccount := oJsonResponse:StringOf("UserPool.EmailConfiguration.EmailSendingAccount")
cUserPoolEmailConfigurationFrom := oJsonResponse:StringOf("UserPool.EmailConfiguration.From")
cUserPoolEmailConfigurationReplyToEmailAddress := oJsonResponse:StringOf("UserPool.EmailConfiguration.ReplyToEmailAddress")
cUserPoolEmailConfigurationSourceArn := oJsonResponse:StringOf("UserPool.EmailConfiguration.SourceArn")
cUserPoolEmailVerificationMessage := oJsonResponse:StringOf("UserPool.EmailVerificationMessage")
cUserPoolEmailVerificationSubject := oJsonResponse:StringOf("UserPool.EmailVerificationSubject")
nUserPoolEstimatedNumberOfUsers := oJsonResponse:IntOf("UserPool.EstimatedNumberOfUsers")
cUserPoolId := oJsonResponse:StringOf("UserPool.Id")
cUserPoolLastModifiedDate := oJsonResponse:StringOf("UserPool.LastModifiedDate")
cUserPoolMfaConfiguration := oJsonResponse:StringOf("UserPool.MfaConfiguration")
cUserPoolName := oJsonResponse:StringOf("UserPool.Name")
nUserPoolPoliciesPasswordPolicyMinimumLength := oJsonResponse:IntOf("UserPool.Policies.PasswordPolicy.MinimumLength")
nUserPoolPoliciesPasswordPolicyRequireLowercase := oJsonResponse:BoolOf("UserPool.Policies.PasswordPolicy.RequireLowercase")
nUserPoolPoliciesPasswordPolicyRequireNumbers := oJsonResponse:BoolOf("UserPool.Policies.PasswordPolicy.RequireNumbers")
nUserPoolPoliciesPasswordPolicyRequireSymbols := oJsonResponse:BoolOf("UserPool.Policies.PasswordPolicy.RequireSymbols")
nUserPoolPoliciesPasswordPolicyRequireUppercase := oJsonResponse:BoolOf("UserPool.Policies.PasswordPolicy.RequireUppercase")
nUserPoolPoliciesPasswordPolicyTemporaryPasswordValidityDays := oJsonResponse:IntOf("UserPool.Policies.PasswordPolicy.TemporaryPasswordValidityDays")
cUserPoolSmsAuthenticationMessage := oJsonResponse:StringOf("UserPool.SmsAuthenticationMessage")
cUserPoolSmsConfigurationExternalId := oJsonResponse:StringOf("UserPool.SmsConfiguration.ExternalId")
cUserPoolSmsConfigurationSnsCallerArn := oJsonResponse:StringOf("UserPool.SmsConfiguration.SnsCallerArn")
cUserPoolSmsVerificationMessage := oJsonResponse:StringOf("UserPool.SmsVerificationMessage")
cUserPoolUserPoolTagsSampleUserPoolTag := oJsonResponse:StringOf("UserPool.UserPoolTags.sampleUserPoolTag")
nUserPoolUsernameConfigurationCaseSensitive := oJsonResponse:BoolOf("UserPool.UsernameConfiguration.CaseSensitive")
cUserPoolVerificationMessageTemplateDefaultEmailOption := oJsonResponse:StringOf("UserPool.VerificationMessageTemplate.DefaultEmailOption")
cUserPoolVerificationMessageTemplateEmailMessage := oJsonResponse:StringOf("UserPool.VerificationMessageTemplate.EmailMessage")
cUserPoolVerificationMessageTemplateEmailSubject := oJsonResponse:StringOf("UserPool.VerificationMessageTemplate.EmailSubject")
cUserPoolVerificationMessageTemplateSmsMessage := oJsonResponse:StringOf("UserPool.VerificationMessageTemplate.SmsMessage")
i := 0
nCount_i := oJsonResponse:SizeOfArray("UserPool.AccountRecoverySetting.RecoveryMechanisms")
DO WHILE i < nCount_i
oJsonResponse:I := i
cName := oJsonResponse:StringOf("UserPool.AccountRecoverySetting.RecoveryMechanisms[i].Name")
nPriority := oJsonResponse:IntOf("UserPool.AccountRecoverySetting.RecoveryMechanisms[i].Priority")
i := i + 1
ENDDO
i := 0
nCount_i := oJsonResponse:SizeOfArray("UserPool.AutoVerifiedAttributes")
DO WHILE i < nCount_i
oJsonResponse:I := i
cStrVal := oJsonResponse:StringOf("UserPool.AutoVerifiedAttributes[i]")
i := i + 1
ENDDO
i := 0
nCount_i := oJsonResponse:SizeOfArray("UserPool.SchemaAttributes")
DO WHILE i < nCount_i
oJsonResponse:I := i
cAttributeDataType := oJsonResponse:StringOf("UserPool.SchemaAttributes[i].AttributeDataType")
nDeveloperOnlyAttribute := oJsonResponse:BoolOf("UserPool.SchemaAttributes[i].DeveloperOnlyAttribute")
nMutable := oJsonResponse:BoolOf("UserPool.SchemaAttributes[i].Mutable")
cName := oJsonResponse:StringOf("UserPool.SchemaAttributes[i].Name")
nRequired := oJsonResponse:BoolOf("UserPool.SchemaAttributes[i].Required")
cStringAttributeConstraintsMaxLength := oJsonResponse:StringOf("UserPool.SchemaAttributes[i].StringAttributeConstraints.MaxLength")
cStringAttributeConstraintsMinLength := oJsonResponse:StringOf("UserPool.SchemaAttributes[i].StringAttributeConstraints.MinLength")
cNumberAttributeConstraintsMinValue := oJsonResponse:StringOf("UserPool.SchemaAttributes[i].NumberAttributeConstraints.MinValue")
i := i + 1
ENDDO
oRest:destroy()
oAuthAws:destroy()
oJson:destroy()
oSbRequestBody:destroy()
oSbResponseBody:destroy()
oJsonResponse:destroy()