Tencent Cloud STS SDK for Python

raw JSON →
3.0.1459 verified Sat May 09 auth: no python

Official Tencent Cloud SDK for accessing the Security Token Service (STS), used to obtain temporary credentials for accessing Tencent Cloud resources. The current version is 3.0.1459 and is updated regularly with new features and fixes.

pip install tencentcloud-sdk-python-sts
error ModuleNotFoundError: No module named 'tencentcloud.sts'
cause Incorrect import path or missing common package.
fix
Install tencentcloud-sdk-python-common and use correct import: from tencentcloud.sts.v20180813 import sts_client
error 'NoneType' object has no attribute 'xxx'
cause API request field not set (None) when required.
fix
Ensure all required fields are set in the request model before passing to client.
breaking Import paths changed after SDK v3.0.xxx; now require version suffix in import path.
fix Use from tencentcloud.sts.v20180813 import sts_client instead of from tencentcloud.sts import sts_client.
deprecated The STS API version 2018-08-13 is current; older versions are no longer supported.
fix Always use v20180813 in import paths.
gotcha Some API models have required fields (e.g., Name in GetFederationTokenRequest) that must not be empty or null.
fix Always set required fields to valid strings/values before calling the API.

Basic usage to get a temporary federation token. Set credentials via environment variables.

from tencentcloud.common import credential
from tencentcloud.sts.v20180813 import sts_client, models

cred = credential.Credential(
    secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
    secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = sts_client.StsClient(cred, 'ap-guangzhou')
req = models.GetFederationTokenRequest()
req.Name = 'test'
req.Policy = ''
resp = client.GetFederationToken(req)
print(resp.Credentials)