Obtaining a Temporary Security Credential Through an Agency or Trust Agency
Function
This API is used to obtain a temporary security credential through an agency or trust agency. The temporary security credential can be used to control access to cloud resources.
Authorization Information
Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
| Action | Access Level | Resource Type (*: required) | Condition Key | Alias | Dependencies |
|---|---|---|---|---|---|
| sts:agencies:assume | Write | agency * | g:ResourceTag/<tag-key> | - |
|
| - |
URI
POST /v5/agencies/assume
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Security-Token | No | String | Definition: security_token field of a temporary security credential. Constraints: When an API is called using a temporary security credential, the HTTP header X-Security-Token must be provided. Range: N/A Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| duration_seconds | No | Integer | Definition: Validity period (in seconds) of the obtained temporary security credential. Constraints: Note that the duration must be less than the maximum session duration set for the agency and cannot exceed 3,600 seconds when the X-Security-Token header is carried. Range: The value ranges from 900 to 43200. Default Value: The default value is 3600. |
| external_id | No | String | Definition: External ID, which prevents confused deputy issues. Constraints: The value contains 2 to 1,224 characters. Range: N/A. Default Value: N/A. |
| policy | No | String | Definition : Custom policy. For details, see Reference. Constraints: The permission scope of the temporary security credential obtained in this session cannot exceed the permission scope specified in the custom policy. The value contains 2 to 2,048 characters. Range: N/A. Default Value: N/A. |
| policy_ids | No | Array of strings | Definition: List of preset policies. The permission scope of the temporary security credential obtained in this session cannot exceed the permissions specified in the preset policies. Constraints: N/A Range: N/A Default Value: N/A |
| agency_urn | Yes | String | Definition: URN of a target agency. Constraints: The value contains 0 to 1,500 characters. Range: N/A Default Value: N/A |
| agency_session_name | Yes | String | Definition: Name of the assumed-agency session. Constraints: The value contains 2 to 128 characters. Range: N/A Default Value: N/A |
| serial_number | No | String | Definition: Serial number of the MFA device bound to the caller. Constraints: The value contains 9 to 256 characters. Range: N/A Default Value: N/A |
| token_code | No | String | Definition: 6-digit code of the MFA device bound to the caller. Constraints: The value contains 6 characters. Range: N/A Default Value: N/A |
| source_identity | No | String | Definition: Identity declared by the initial caller in the call chain. Constraints: The value contains 2 to 64 characters. Range: N/A Default Value: N/A |
| tags | No | Array of TagDto objects | Definition: List of custom tags. Constraints: N/A Range: N/A Default Value: N/A |
| transitive_tag_keys | No | Array of strings | Definition: List of tag keys that are continuously transparently transmitted along with the temporary security credential call chain. Constraints: N/A Range: N/A Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Definition: Tag key. Constraints: The value contains 1 to 128 characters. Range: N/A Default Value: N/A |
| value | Yes | String | Definition: Tag value. Constraints: The value contains 0 to 255 characters. Range: The value can be an empty string but cannot be null. Default Value: N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| source_identity | String | Definition: Identity declared by the initial caller in the call chain. Range: N/A |
| assumed_agency | AssumedAgencyDto object | Definition: Information about an agency session or trust agency session. Range: N/A |
| credentials | CredentialsDto object | Definition: Generated temporary security credentials. Range: N/A |
| Parameter | Type | Description |
|---|---|---|
| urn | String | Definition: URN of an agency session or trust agency session. Range: N/A |
| id | String | Definition: Unique identifier of an agency session or trust agency session, including the agency ID and agency session name. Range: N/A |
| Parameter | Type | Description |
|---|---|---|
| access_key_id | String | Definition: AK of the temporary security credential. Range: N/A |
| expiration | String | Definition: Expiration time of the temporary security credential. Range: N/A |
| secret_access_key | String | Definition: SK of the temporary security credential. Range: N/A |
| security_token | String | Definition: security_token of the temporary security credential. Range: N/A |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition : Error code. For details, see Error Code. Range: The format is STS5.XXXX, for example, STS5.1001. |
| error_msg | String | Definition : Error message. For details, see Error Message. Range: N/A. |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition : Error code. For details, see Error Code. Range: The format is STS5.XXXX, for example, STS5.1001. |
| error_msg | String | Definition : Error message. For details, see Error Message. Range: N/A. |
| encoded_authorization_message | String | Definition : Encrypted details returned when the authentication fails, which are used to locate authentication problems. The STS5 decryption API can be used for decryption. For details, see API link. Range: N/A. |
Status code: 404
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition : Error code. For details, see Error Code. Range: The format is STS5.XXXX, for example, STS5.1001. |
| error_msg | String | Definition : Error message. For details, see Error Message. Range: N/A. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition : Error code. For details, see Error Code. Range: The format is STS5.XXXX, for example, STS5.1001. |
| error_msg | String | Definition : Error message. For details, see Error Message. Range: N/A. |
Example Requests
Obtaining a temporary security credential through agency Y0yfCQYJGO of account 27680d67da6b47eb82d00a1a118be145
POST https://{endpoint}/v5/agencies/assume
{
"duration_seconds" : 3600,
"agency_urn" : "iam::27680d67da6b47eb82d00a1a118be145:agency:Y0yfCQYJGO",
"agency_session_name" : "session1"
} Example Responses
Status code: 200
Successful
{
"assumed_agency" : {
"urn" : "sts::{account_id}::assumed-agency:{agency_name}/{agency_session_name}",
"id" : "{agency_id}:{agency_session_name}"
},
"credentials" : {
"access_key_id" : "HSTANO...XBS55JLJ3",
"secret_access_key" : "EoWCQrr...SCcw4Whkt2aXKWAr",
"security_token" : "hQpjbi1XXXXXX...XXXXXKbhBbA0TQ==",
"expiration" : "2022-09-07T03:27:51.158Z"
}
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Successful |
| 400 | Bad request |
| 403 | Forbidden |
| 404 | Not found |
| 500 | Server error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot