Skip to main content

get_federation_token

Function get_federation_token 

Source
pub async fn get_federation_token(
    secret_id: &str,
    secret_key: &str,
    region: &str,
    policy: Policy,
    duration_secs: u64,
) -> ApiResult<TempCredentials>
Expand description

调用 STS GetFederationToken 获取临时密钥

使用腾讯云主密钥换取联合身份临时凭证, 前端凭此凭证在有效期内直接访问 COS。

§参数

  • secret_id: 腾讯云主账号 SecretId
  • secret_key: 腾讯云主账号 SecretKey
  • region: COS 区域
  • policy: 权限策略(由 build_put_policybuild_get_policy 生成)
  • duration_secs: 临时凭证有效期(秒)

§返回值

返回包含临时密钥和 SessionToken 的 TempCredentials

§Errors

  • AppError::Oss — SecretId/SecretKey 为空或 STS 接口调用失败

§Panics

不 panic。所有错误通过 ApiResult 返回。