Registry / aws / aliyun-python-sdk-sts

aliyun-python-sdk-sts

JSON →
library3.1.3pypypi✓ verified 84d ago

The official Alibaba Cloud (Aliyun) STS (Security Token Service) SDK for Python. Version 3.1.3. Allows obtaining temporary security credentials (access keys) for accessing Alibaba Cloud resources. Release cadence is low, typically updated alongside the core SDK.

pip install aliyun-python-sdk-sts
INSTALL
IMPORT
SIG · ALIYUN-PYTHON-SDK-
A
aliyun-python-sdk-sts
awspythonv3.1.3
Install
3.9s avg
Import
291ms
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.298s · 39.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.284s · 40MB
37MB installed
● package 37MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

StsRequest
from aliyunsdksts.request.v20150401 import AssumeRoleRequest
import sts
Wrong import; the SDK uses the full request class.
StsClient
from aliyunsdkcore.client import AcsClient
from aliyunsdksts.client import AcsClient
The client is from aliyunsdkcore, not from the sts package.

Assume a role using STS to get temporary credentials.

from aliyunsdkcore.client import AcsClient from aliyunsdksts.request.v20150401 import AssumeRoleRequest import json client = AcsClient( os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', ''), os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', ''), 'cn-hangzhou' ) request = AssumeRoleRequest() request.set_RoleArn('acs:ram::1234567890:role/ecsbackup') request.set_RoleSessionName('session-test') response = client.do_action_with_exception(request) print(json.loads(response))
Debug
Known issues
breakingIn version 3.x, the base SDK was restructured. All request classes are now in aliyunsdk<service>.request. Do not use the old AliyunApiClient pattern.
fix
Use AcsClient from aliyunsdkcore.client and request classes from aliyunsdksts.request
affects: >=3.0.0
gotchaThe STS SDK does not install the core SDK automatically. If you only install aliyun-python-sdk-sts, you will get ImportError for AcsClient.
fix
Install both: pip install aliyun-python-sdk-core aliyun-python-sdk-sts
affects: all
deprecatedThe older method client.do_action(request) (without _with_exception) is deprecated; it returns raw bytes without error handling.
fix
Use client.do_action_with_exception(request) which returns a string.
affects: <3.0.0
Errors
Common errors & fixes
ImportError: No module named 'aliyunsdkcore'
Missing dependency aliyun-python-sdk-core.
fix
Run: pip install aliyun-python-sdk-core
AttributeError: module 'aliyunsdksts' has no attribute 'request'
Wrong import statement; trying to import the module instead of the request class.
fix
Use: from aliyunsdksts.request.v20150401 import AssumeRoleRequest
aliyunsdkcore.exception.ServerException: HTTP Status: 404 Error: InvalidParameter.RoleArn
RoleArn parameter is missing or incorrectly formatted.
fix
Ensure RoleArn is set with the correct format: acs:ram::<account-id>:role/<role-name>
Upgrade
Version history
3.1.3latest on PyPI · released Jun 30, 2025
Audit
Dependencies
aliyun-python-sdk-corerequiredRequired for Alibaba Cloud SDK infrastructure; not automatically installed by this package.
Agent activity
63 hits · last 30 days
node
52
OpenAI (training)
2
Perplexity
1
Resources
aliyun-python-sdk-sts — pip install aliyun-python-sdk-sts · libregistry