You can use Alibaba Cloud SDKs to initiate signature-verified RESTful API requests to Object Storage Service (OSS). This way, the SDKs automatically generate signatures for the requests. If you initiate RESTful API requests to OSS without using Alibaba Cloud SDKs, you must write code to calculate signatures and add the signatures to the requests.
Use the AccessKey pair of a RAM user to initiate a request to OSS
The following procedure shows how to use the AccessKey pair of a RAM user to initiate a request to OSS:
- Use the AccessKey pair of a RAM user to initialize an OSSClient instance.
- Call the method that is provided by OSSClient to initiate a request to OSS.
- The OSSClient instance uses the AccessKey pair of the RAM user to generate a signature and adds the signature to the request.
For more information, see Use the AccessKey pair of a RAM user to initiate a request.
Use temporary access credentials obtained from STS to initiate a request to OSS
RAM users can use Alibaba Cloud SDKs to obtain temporary access credentials from STS, and use the temporary access credentials to access OSS resources. The temporary access credentials become invalid after the specified validity period expires.
The following procedure shows how to use temporary access credentials to initiate a request to OSS:
- Use the AccessKey pair of a RAM user to initialize an STSClient instance.
- Call the AssumeRole method that is provided by STS to obtain temporary access credentials of the RAM role that is attached with a specified policy.
- Use the temporary access credentials to initialize an OSSClient instance.
- Call the method that is provided by OSSClient to initiate a request to OSS.
- The OSSClient instance uses the temporary access credentials that are obtained from STS to generate a signature and adds the signature to the request.
For more information, see Use a temporary credential provided by STS to access OSS.
Alibaba Cloud SDKs
Alibaba Cloud provides SDKs in the following programming languages: