This topic provides the download URLs of the Python SDK packages that are required for you to use STS. This topic also describes how to use the STS SDK for Python.

Download URLs

You can download the SDK packages from the following links:

Use the STS SDK for Python

#!/usr/bin/env python
from aliyunsdkcore import client
from aliyunsdkcore.profile import region_provider
from aliyunsdksts.request.v20150401 import AssumeRoleRequest
# Construct an Alibaba Cloud client. The client will be used to send a request.
# When you construct the client, set the AccessKey ID and AccessKey secret.
REGIONID = 'cn-shanghai'
# Specify the STS endpoint that you want to access.
region_provider.add_endpoint('Sts', REGIONID, ENDPOINT)
# Initialize the client.
clt = client.AcsClient('<access-key-id>','<access-key-secret>', REGIONID)
# Construct an AssumeRole request.
request = AssumeRoleRequest.AssumeRoleRequest()
# Specify the Alibaba Cloud Resource Name (ARN) of the RAM role.
# Specify a role session name, which is used to identify the RAM user who assumes the RAM role.
# Specify a policy to grant the returned STS token fewer permissions than those granted to the RAM role.
# Issue the request and obtain a response.
response = clt.do_action_with_exception(request)
print response
  • For the list of STS endpoints in different regions, see Endpoints.
  • For more information about the AssumeRole API operation, see AssumeRole.