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
(Tcl) S3 List Buckets using an STS Session TokenThis is an example showing how to use an STS session token in an Amazon AWS request. This example will list S3 buckets using a previously obtained session token.
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. # See Get AWS STS Session Token for sample code to get the session token XML. set xmlToken [new_CkXml] set success [CkXml_LoadXmlFile $xmlToken "qa_data/tokens/aws_session_token.xml"] if {$success == 0} then { puts [CkXml_lastErrorText $xmlToken] delete_CkXml $xmlToken exit } set rest [new_CkRest] # Connect to the Amazon AWS REST server. set bTls 1 set port 443 set bAutoReconnect 1 set success [CkRest_Connect $rest "s3.amazonaws.com" $port $bTls $bAutoReconnect] # Provide AWS credentials for the REST call. set authAws [new_CkAuthAws] # The purpose of this example is to show how to use the temporary AccessKeyId, SecretAccessKey, and SessionToken. CkAuthAws_put_AccessKey $authAws [CkXml_getChildContent $xmlToken "GetSessionTokenResult|Credentials|AccessKeyId"] CkAuthAws_put_SecretKey $authAws [CkXml_getChildContent $xmlToken "GetSessionTokenResult|Credentials|SecretAccessKey"] CkAuthAws_put_ServiceName $authAws "s3" set success [CkRest_SetAuthAws $rest $authAws] CkRest_AddQueryParam $rest "X-Amz-Security-Token" [CkXml_getChildContent $xmlToken "GetSessionTokenResult|Credentials|SessionToken"] set sbResponse [new_CkStringBuilder] set success [CkRest_FullRequestNoBodySb $rest "GET" "/" $sbResponse] if {$success != 1} then { puts [CkRest_lastErrorText $rest] delete_CkXml $xmlToken delete_CkRest $rest delete_CkAuthAws $authAws delete_CkStringBuilder $sbResponse exit } set statusCode [CkRest_get_ResponseStatusCode $rest] puts "Response status code = $statusCode" set xml [new_CkXml] CkXml_LoadSb $xml $sbResponse 1 puts [CkXml_getXml $xml] if {$statusCode != 200} then { puts "Failed. See error information in the XML." delete_CkXml $xmlToken delete_CkRest $rest delete_CkAuthAws $authAws delete_CkStringBuilder $sbResponse delete_CkXml $xml exit } delete_CkXml $xmlToken delete_CkRest $rest delete_CkAuthAws $authAws delete_CkStringBuilder $sbResponse delete_CkXml $xml |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.