View Source COS.STS (tencent_cloud_cos v0.1.1)
临时密钥生成及使用指引 - 腾讯云文档
Link to this section Summary
Link to this section Functions
@spec get_credential( name :: binary(), policy :: map(), region :: binary(), opts :: [ expired_at: DateTime.t(), expire_in: COS.Utils.expire_in(), tesla_opts: Tesla.Env.opts() ] ) :: Tesla.Env.t()
获取联合身份临时访问凭证 - 腾讯云文档
示例
示例
iex> COS.STS.get_credential(
"cos-sts-elixir",
%{
version: "2.0",
statement: [
%{
effect: "allow",
action: ["cos:PutObject"],
resource: ["qcs::cos:ap-beijing:uid/1250000000:bucket-1250000000/*"]
}
]
},
"ap-beijing"
)
{:ok, %Tesla.Env{
body: %{
"credentials" => %{
"token" => "xxx",
...
}
},
...
}}
iex> COS.STS.get_credential(
"cos-sts-elixir",
%{
version: "2.0",
statement: [
%{
effect: "allow",
action: ["cos:PutObject"],
resource: ["invalid resouce"]
}
]
},
"ap-beijing"
)
{:error, %Tesla.Env{
body: %{
"error" => %{
"code" => "InvalidParameter.ResouceError",
"message" => "resource error"
}
"request_id" => "6734caac-d3bf-4465-adf3-2e300e5063ce"
},
...
}}