|  | 
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
| (Lianja) 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. 
 // 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. loXmlToken = createobject("CkXml") llSuccess = loXmlToken.LoadXmlFile("qa_data/tokens/aws_session_token.xml") if (llSuccess = .F.) then ? loXmlToken.LastErrorText release loXmlToken return endif loRest = createobject("CkRest") // Connect to the Amazon AWS REST server. llBTls = .T. lnPort = 443 llBAutoReconnect = .T. llSuccess = loRest.Connect("s3.amazonaws.com",lnPort,llBTls,llBAutoReconnect) // Provide AWS credentials for the REST call. loAuthAws = createobject("CkAuthAws") // The purpose of this example is to show how to use the temporary AccessKeyId, SecretAccessKey, and SessionToken. loAuthAws.AccessKey = loXmlToken.GetChildContent("GetSessionTokenResult|Credentials|AccessKeyId") loAuthAws.SecretKey = loXmlToken.GetChildContent("GetSessionTokenResult|Credentials|SecretAccessKey") loAuthAws.ServiceName = "s3" llSuccess = loRest.SetAuthAws(loAuthAws) loRest.AddQueryParam("X-Amz-Security-Token",loXmlToken.GetChildContent("GetSessionTokenResult|Credentials|SessionToken")) loSbResponse = createobject("CkStringBuilder") llSuccess = loRest.FullRequestNoBodySb("GET","/",loSbResponse) if (llSuccess <> .T.) then ? loRest.LastErrorText release loXmlToken release loRest release loAuthAws release loSbResponse return endif lnStatusCode = loRest.ResponseStatusCode ? "Response status code = " + str(lnStatusCode) loXml = createobject("CkXml") loXml.LoadSb(loSbResponse,.T.) ? loXml.GetXml() if (lnStatusCode <> 200) then ? "Failed. See error information in the XML." release loXmlToken release loRest release loAuthAws release loSbResponse release loXml return endif release loXmlToken release loRest release loAuthAws release loSbResponse release loXml | ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.