Skip to content

Commit 525a889

Browse files
author
yuguo.dtpe
committed
fix(doc): integration doc add STS Token authentication method description
1 parent 7b8b803 commit 525a889

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

SDK_Integration_zh.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [环境要求](#环境要求)
55
- [访问凭据](#访问凭据)
66
- [AK、SK设置](#aksk设置)
7+
- [STS Token设置](#sts-token设置)
78
- [EndPoint配置](#endpoint配置)
89
- [自定义Endpoint](#自定义endpoint)
910
- [自定义RegionId](#自定义regionid)
@@ -40,7 +41,7 @@
4041

4142
# 访问凭据
4243

43-
为保障资源访问安全,火山引擎 Python SDK 目前暂时只支持 **AK/SK**认证设置。
44+
为保障资源访问安全,火山引擎 Python SDK 目前支持 `AK/SK``STS Token` 认证设置。
4445

4546
## AK、SK设置
4647

@@ -87,6 +88,53 @@ except ApiException as e:
8788
pass
8889
```
8990

91+
## STS Token设置
92+
93+
STS(Security Token Service)是火山引擎提供的临时访问凭证机制。开发者通过服务端调用 STS 接口获取临时凭证(临时 AK、SK 和 Token),有效期可配置,适用于安全要求较高的场景。
94+
95+
> ⚠️ 注意事项
96+
>
97+
> 1. 最小权限: 仅授予调用方访问所需资源的最小权限,避免使用 * 通配符授予全资源、全操作权限。
98+
> 2. 设置合理的有效期: 请根据实际情况设置合理有效期,越短越安全,建议不要超过1小时。
99+
100+
支持`configuration`级别全局配置和接口级别的运行时参数设置`RuntimeOption`;`RuntimeOption`设置会覆盖`configuration`全局配置。
101+
102+
**代码示例:**
103+
```python
104+
import volcenginesdkcore,volcenginesdkecs
105+
from volcenginesdkcore.rest import ApiException
106+
from volcenginesdkcore.interceptor import RuntimeOption
107+
108+
# 全局设置
109+
configuration = volcenginesdkcore.Configuration()
110+
configuration.ak = "Your ak"
111+
configuration.sk = "Your sk"
112+
configuration.session_token = "Your session token"
113+
configuration.debug = True
114+
volcenginesdkcore.Configuration.set_default(configuration)
115+
116+
# 接口级别运行时参数设置,会覆盖全局配置
117+
runtime_options = RuntimeOption(
118+
ak = "Your ak",
119+
sk = "Your sk",
120+
session_token="Your session token",
121+
client_side_validation = True, # 开启客户端校验,默认开启
122+
)
123+
api_instance = volcenginesdkecs.ECSApi()
124+
create_command_request = volcenginesdkecs.CreateCommandRequest(
125+
command_content="ls -l",
126+
description="Your command description",
127+
name="Your command name",
128+
type="command",
129+
_configuration=runtime_options, # 配置运行时参数
130+
)
131+
try:
132+
api_instance.create_command(create_command_request)
133+
except ApiException as e:
134+
pass
135+
```
136+
137+
90138

91139
# EndPoint配置
92140

0 commit comments

Comments
 (0)