Sample code for 30+ languages & platforms
PureBasic Requires Chilkat v11.6.0+

S3: List All Buckets with STS Credentials

See more AWS Security Token Service Examples

Uses all three temporary credential fields from the private XML file produced by either GetSessionToken or AssumeRole. Validates the response root, nonempty credential fields and ISO 8601 expiration before connecting, then checks expiry with a 60-second margin before each page. Does not print credential data, renew it automatically, or infer freshness merely from the presence of a file.

Uses Chilkat.Rest/AuthAws with Signature Version 4, service s3, explicit us-west-2 signing region, a matching regional endpoint, and TLS certificate verification. STS issuance region does not fix the service-request signing region. The session token is sent in the signed query on every request; do not log the request URL. Configure the appropriate endpoint for other partitions.

Requests max-buckets=100 and follows S3's ContinuationToken, including after an empty page. Tokens are opaque, repeated tokens stop enumeration, and a 10,000-page bound reports incomplete results. Requires s3:ListAllMyBuckets. Lists general purpose buckets owned by the authenticated account, not every bucket the caller can access. Directory buckets are excluded. Does not depend on Owner.DisplayName. Pagination is important for accounts with elevated bucket quotas, where unpaginated listing is rejected.

Pre-protect the credential file and output environment. This read-only consumer does not change the XML file. A production credential provider should coordinate refresh and publication of a complete credential set rather than partially updating it while requests are running.

AWS API reference

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkAuthAws.pb"
IncludeFile "CkDateTime.pb"
IncludeFile "CkSocket.pb"
IncludeFile "CkXml.pb"
IncludeFile "CkHashtable.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"

Procedure ChilkatExample()

    success.i = 0

    stringCompare.i = CkStringBuilder::ckCreate()
    If stringCompare.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  Assumes Chilkat is unlocked. See Global Unlock Sample.
    ;  Accept the private XML handoff from either GetSessionToken or AssumeRole.
    xmlToken.i = CkXml::ckCreate()
    If xmlToken.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkXml::setCkStrict(xmlToken, 1)
    success = CkXml::ckLoadXmlFile(xmlToken,"qa_data/tokens/aws_session_token.xml")
    If success <> 1
        Debug "Could not load the private STS credential file."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        ProcedureReturn
    EndIf

    credentialPath.s = ""
    CkStringBuilder::ckSetString(stringCompare,CkXml::ckTag(xmlToken))
    stringMatch1.i = CkStringBuilder::ckContentsEqual(stringCompare,"GetSessionTokenResponse",1)
    If stringMatch1 = 1
        credentialPath = "GetSessionTokenResult|Credentials"
    EndIf

    CkStringBuilder::ckSetString(stringCompare,CkXml::ckTag(xmlToken))
    stringMatch2.i = CkStringBuilder::ckContentsEqual(stringCompare,"AssumeRoleResponse",1)
    If stringMatch2 = 1
        credentialPath = "AssumeRoleResult|Credentials"
    EndIf

    CkStringBuilder::ckSetString(stringCompare,credentialPath)
    stringMatch3.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
    If stringMatch3 = 1
        Debug "Expected a GetSessionToken or AssumeRole credential response."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        ProcedureReturn
    EndIf

    accessKey.s
    secretKey.s
    sessionToken.s
    expiration.s
    path.i = CkStringBuilder::ckCreate()
    If path.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckSetString(path,credentialPath)
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckAppend(path,"|AccessKeyId")
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    accessKey = CkXml::ckGetChildContent(xmlToken,CkStringBuilder::ckGetAsString(path))
    CkStringBuilder::ckSetString(stringCompare,accessKey)
    stringMatch4.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
    If (CkXml::ckLastMethodSuccess(xmlToken) <> 1) OR (stringMatch4 = 1)
        Debug "Missing or empty AccessKeyId."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckSetString(path,credentialPath)
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckAppend(path,"|SecretAccessKey")
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    secretKey = CkXml::ckGetChildContent(xmlToken,CkStringBuilder::ckGetAsString(path))
    CkStringBuilder::ckSetString(stringCompare,secretKey)
    stringMatch5.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
    If (CkXml::ckLastMethodSuccess(xmlToken) <> 1) OR (stringMatch5 = 1)
        Debug "Missing or empty SecretAccessKey."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckSetString(path,credentialPath)
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckAppend(path,"|SessionToken")
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    sessionToken = CkXml::ckGetChildContent(xmlToken,CkStringBuilder::ckGetAsString(path))
    CkStringBuilder::ckSetString(stringCompare,sessionToken)
    stringMatch6.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
    If (CkXml::ckLastMethodSuccess(xmlToken) <> 1) OR (stringMatch6 = 1)
        Debug "Missing or empty SessionToken."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckSetString(path,credentialPath)
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    success = CkStringBuilder::ckAppend(path,"|Expiration")
    If success <> 1
        Debug "Could not build credential path."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    expiration = CkXml::ckGetChildContent(xmlToken,CkStringBuilder::ckGetAsString(path))
    CkStringBuilder::ckSetString(stringCompare,expiration)
    stringMatch7.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
    If (CkXml::ckLastMethodSuccess(xmlToken) <> 1) OR (stringMatch7 = 1)
        Debug "Missing or empty Expiration."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        ProcedureReturn
    EndIf

    expires.i = CkDateTime::ckCreate()
    If expires.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    now.i = CkDateTime::ckCreate()
    If now.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkDateTime::ckSetFromTimestamp(expires,expiration)
    If success <> 1
        Debug "Stored expiration is invalid."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        CkDateTime::ckDispose(expires)
        CkDateTime::ckDispose(now)
        ProcedureReturn
    EndIf

    success = CkDateTime::ckSetFromCurrentSystemTime(now)
    If success <> 1
        Debug "Could not read current time."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        CkDateTime::ckDispose(expires)
        CkDateTime::ckDispose(now)
        ProcedureReturn
    EndIf

    If CkDateTime::ckDiffSeconds(expires,now) <= 60
        Debug "Stored credentials are expired or expire within 60 seconds; obtain fresh credentials."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        CkDateTime::ckDispose(expires)
        CkDateTime::ckDispose(now)
        ProcedureReturn
    EndIf

    ;  This S3 region is independent of the region that issued the STS credentials.
    region.s = "us-west-2"
    endpoint.i = CkStringBuilder::ckCreate()
    If endpoint.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkStringBuilder::ckAppend(endpoint,"s3.")
    CkStringBuilder::ckAppend(endpoint,region)
    CkStringBuilder::ckAppend(endpoint,".amazonaws.com")
    aws.i = CkAuthAws::ckCreate()
    If aws.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkAuthAws::setCkAccessKey(aws, accessKey)
    CkAuthAws::setCkSecretKey(aws, secretKey)
    CkAuthAws::setCkRegion(aws, region)
    CkAuthAws::setCkServiceName(aws, "s3")
    CkAuthAws::setCkSignatureVersion(aws, 4)
    rest.i = CkRest::ckCreate()
    If rest.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkRest::setCkConnectTimeoutMs(rest, 20000)
    CkRest::setCkIdleTimeoutMs(rest, 60000)
    CkRest::setCkVerboseLogging(rest, 0)
    success = CkRest::ckSetAuthAws(rest,aws)
    If success <> 1
        Debug "Could not configure request signing."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        CkDateTime::ckDispose(expires)
        CkDateTime::ckDispose(now)
        CkStringBuilder::ckDispose(endpoint)
        CkAuthAws::ckDispose(aws)
        CkRest::ckDispose(rest)
        ProcedureReturn
    EndIf

    ;  Keep this verified Socket alive while Rest uses its connection.
    connection.i = CkSocket::ckCreate()
    If connection.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkSocket::setCkRequireSslCertVerify(connection, 1)
    CkSocket::setCkMaxReadIdleMs(connection, 60000)
    CkSocket::setCkMaxSendIdleMs(connection, 60000)
    success = CkSocket::ckConnect(connection,CkStringBuilder::ckGetAsString(endpoint),443,1,20000)
    If success <> 1
        Debug "TLS connection failed; inspect diagnostics privately."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        CkDateTime::ckDispose(expires)
        CkDateTime::ckDispose(now)
        CkStringBuilder::ckDispose(endpoint)
        CkAuthAws::ckDispose(aws)
        CkRest::ckDispose(rest)
        CkSocket::ckDispose(connection)
        ProcedureReturn
    EndIf

    success = CkRest::ckUseConnection(rest,connection,1)
    If success <> 1
        Debug "Could not attach TLS connection."
        CkStringBuilder::ckDispose(stringCompare)
        CkXml::ckDispose(xmlToken)
        CkStringBuilder::ckDispose(path)
        CkDateTime::ckDispose(expires)
        CkDateTime::ckDispose(now)
        CkStringBuilder::ckDispose(endpoint)
        CkAuthAws::ckDispose(aws)
        CkRest::ckDispose(rest)
        CkSocket::ckDispose(connection)
        ProcedureReturn
    EndIf

    xml.i = CkXml::ckCreate()
    If xml.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkXml::setCkStrict(xml, 1)
    value.s
    seenTokens.i = CkHashtable::ckCreate()
    If seenTokens.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    continuation.s = ""
    responseXml.s
    page.i = 0
    index.i
    more.i = 1
    While (more = 1)
        If page = 10000
            Debug "Page bound reached; bucket enumeration is incomplete."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        success = CkDateTime::ckSetFromCurrentSystemTime(now)
        If success <> 1
            Debug "Could not read current time."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        If CkDateTime::ckDiffSeconds(expires,now) <= 60
            Debug "Credentials are expiring; obtain fresh credentials before continuing the listing."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        page = page + 1
        success = CkRest::ckClearAllQueryParams(rest)
        If success <> 1
            Debug "Could not clear parameters from the previous page."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        ;  All three credential components are required. Never log this signed URL.
        success = CkRest::ckAddQueryParam(rest,"X-Amz-Security-Token",sessionToken)
        If success <> 1
            Debug "Could not set X-Amz-Security-Token."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        success = CkRest::ckAddQueryParam(rest,"max-buckets","100")
        If success <> 1
            Debug "Could not set max-buckets."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        CkStringBuilder::ckSetString(stringCompare,continuation)
        stringMatch8.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
        If stringMatch8 <> 1
            success = CkRest::ckAddQueryParam(rest,"continuation-token",continuation)
            If success <> 1
                Debug "Could not set continuation-token."
                CkStringBuilder::ckDispose(stringCompare)
                CkXml::ckDispose(xmlToken)
                CkStringBuilder::ckDispose(path)
                CkDateTime::ckDispose(expires)
                CkDateTime::ckDispose(now)
                CkStringBuilder::ckDispose(endpoint)
                CkAuthAws::ckDispose(aws)
                CkRest::ckDispose(rest)
                CkSocket::ckDispose(connection)
                CkXml::ckDispose(xml)
                CkHashtable::ckDispose(seenTokens)
                ProcedureReturn
            EndIf

        EndIf

        responseXml = CkRest::ckFullRequestNoBody(rest,"GET","/")
        If CkRest::ckLastMethodSuccess(rest) <> 1
            Debug "S3 request did not complete; enumeration is incomplete."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        success = CkXml::ckLoadXml(xml,responseXml)
        If CkRest::ckResponseStatusCode(rest) <> 200
            Debug "S3 HTTP status: " + Str(CkRest::ckResponseStatusCode(rest))
            If success = 1
                value = CkXml::ckGetChildContent(xml,"Code")
                If CkXml::ckLastMethodSuccess(xml) = 1
                    Debug "AWS error code: " + value
                EndIf

                value = CkXml::ckGetChildContent(xml,"RequestId")
                If CkXml::ckLastMethodSuccess(xml) = 1
                    Debug "AWS request ID: " + value
                EndIf

            EndIf

            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        If success <> 1
            Debug "Invalid S3 XML response."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        CkStringBuilder::ckSetString(stringCompare,CkXml::ckTag(xml))
        stringMatch9.i = CkStringBuilder::ckContentsEqual(stringCompare,"ListAllMyBucketsResult",1)
        If stringMatch9 <> 1
            Debug "Unexpected S3 response root."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        If CkXml::ckHasChildWithTag(xml,"Buckets") <> 1
            Debug "Missing Buckets collection."
            CkStringBuilder::ckDispose(stringCompare)
            CkXml::ckDispose(xmlToken)
            CkStringBuilder::ckDispose(path)
            CkDateTime::ckDispose(expires)
            CkDateTime::ckDispose(now)
            CkStringBuilder::ckDispose(endpoint)
            CkAuthAws::ckDispose(aws)
            CkRest::ckDispose(rest)
            CkSocket::ckDispose(connection)
            CkXml::ckDispose(xml)
            CkHashtable::ckDispose(seenTokens)
            ProcedureReturn
        EndIf

        index = 0
        While (index < CkXml::ckNumChildrenAt(xml,"Buckets"))
            CkXml::setCkI(xml, index)
            value = CkXml::ckGetChildContent(xml,"Buckets|Bucket[i]|Name")
            CkStringBuilder::ckSetString(stringCompare,value)
            stringMatch10.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
            If (CkXml::ckLastMethodSuccess(xml) <> 1) OR (stringMatch10 = 1)
                Debug "Missing or empty Buckets|Bucket[i]|Name."
                CkStringBuilder::ckDispose(stringCompare)
                CkXml::ckDispose(xmlToken)
                CkStringBuilder::ckDispose(path)
                CkDateTime::ckDispose(expires)
                CkDateTime::ckDispose(now)
                CkStringBuilder::ckDispose(endpoint)
                CkAuthAws::ckDispose(aws)
                CkRest::ckDispose(rest)
                CkSocket::ckDispose(connection)
                CkXml::ckDispose(xml)
                CkHashtable::ckDispose(seenTokens)
                ProcedureReturn
            EndIf

            Debug "Bucket: " + value
            index = index + 1
        Wend
        continuation = ""
        If CkXml::ckHasChildWithTag(xml,"ContinuationToken") = 1
            continuation = CkXml::ckGetChildContent(xml,"ContinuationToken")
            If CkXml::ckLastMethodSuccess(xml) <> 1
                Debug "Invalid continuation token."
                CkStringBuilder::ckDispose(stringCompare)
                CkXml::ckDispose(xmlToken)
                CkStringBuilder::ckDispose(path)
                CkDateTime::ckDispose(expires)
                CkDateTime::ckDispose(now)
                CkStringBuilder::ckDispose(endpoint)
                CkAuthAws::ckDispose(aws)
                CkRest::ckDispose(rest)
                CkSocket::ckDispose(connection)
                CkXml::ckDispose(xml)
                CkHashtable::ckDispose(seenTokens)
                ProcedureReturn
            EndIf

        EndIf

        more = 0
        CkStringBuilder::ckSetString(stringCompare,continuation)
        stringMatch11.i = CkStringBuilder::ckContentsEqual(stringCompare,"",1)
        If stringMatch11 <> 1
            If CkHashtable::ckContains(seenTokens,continuation) = 1
                Debug "Repeated continuation token; enumeration is incomplete."
                CkStringBuilder::ckDispose(stringCompare)
                CkXml::ckDispose(xmlToken)
                CkStringBuilder::ckDispose(path)
                CkDateTime::ckDispose(expires)
                CkDateTime::ckDispose(now)
                CkStringBuilder::ckDispose(endpoint)
                CkAuthAws::ckDispose(aws)
                CkRest::ckDispose(rest)
                CkSocket::ckDispose(connection)
                CkXml::ckDispose(xml)
                CkHashtable::ckDispose(seenTokens)
                ProcedureReturn
            EndIf

            success = CkHashtable::ckAddStr(seenTokens,continuation,"seen")
            If success <> 1
                Debug "Could not track pagination."
                CkStringBuilder::ckDispose(stringCompare)
                CkXml::ckDispose(xmlToken)
                CkStringBuilder::ckDispose(path)
                CkDateTime::ckDispose(expires)
                CkDateTime::ckDispose(now)
                CkStringBuilder::ckDispose(endpoint)
                CkAuthAws::ckDispose(aws)
                CkRest::ckDispose(rest)
                CkSocket::ckDispose(connection)
                CkXml::ckDispose(xml)
                CkHashtable::ckDispose(seenTokens)
                ProcedureReturn
            EndIf

            more = 1
        EndIf

    Wend
    Debug "Bucket enumeration complete."


    CkStringBuilder::ckDispose(stringCompare)
    CkXml::ckDispose(xmlToken)
    CkStringBuilder::ckDispose(path)
    CkDateTime::ckDispose(expires)
    CkDateTime::ckDispose(now)
    CkStringBuilder::ckDispose(endpoint)
    CkAuthAws::ckDispose(aws)
    CkRest::ckDispose(rest)
    CkSocket::ckDispose(connection)
    CkXml::ckDispose(xml)
    CkHashtable::ckDispose(seenTokens)


    ProcedureReturn
EndProcedure