You can obtain a temporary AK/SK and security token (offline AK/SK) by using a user token, agency token, and federated token. A temporary AK/SK is a token with temporary permissions issued to users. It conforms to the principle of least privilege and can be used to temporarily access OBS.
POST /v3.0/OS-CREDENTIAL/securitytokens
Parameter | Mandatory | Type | Description |
|---|---|---|---|
X-Auth-Token | Yes | String | Token with permissions of the Agent Operator policy. |
Content-Type | Yes | String | Fill application/json;charset=utf8 in this field. |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
Content-Type | Yes | String | Fill application/json;charset=utf8 in this field. |
X-Auth-Token | No | String | User token or federated token required for obtaining a temporary AK/SK. You need to specify either this parameter or the token ID in the request body. This parameter takes the precedence. |
Name | Type | Mandatory | Description |
|---|---|---|---|
TokenAuth object | Yes | Authentication information. |
Name | Type | Mandatory | Description |
|---|---|---|---|
TokenAuthIdentity object | Yes | Authentication parameters. |
Name | Type | Mandatory | Description |
|---|---|---|---|
methods | Array of strings | Yes | Authentication method. The value of this parameter is ["token"]. |
IdentityToken object | No | IAM user token, federated user token, or agency token. The id in this parameter is the same as that of X-Auth-Token in the request header. This parameter is to be discarded. | |
ServicePolicy object | No | Content of the custom policy. |
Name | Type | Mandatory | Description |
|---|---|---|---|
id | string | No | Token ID. Same as the X-Auth-Token in the request header. This parameter is to be discarded. |
duration_seconds | integer | No | Validity period (in seconds) of an AK/SK and security token. The value ranges from 15 minutes to 24 hours. The default value is 15min. |
Name | Type | Mandatory | Description |
|---|---|---|---|
Version | string | Yes | Policy version. When creating a custom policy, set this parameter to 1.1.
|
Array of ServiceStatement objects | Yes | Statement of the policy, which describes details of a custom policy. |
Name | Type | Mandatory | Description |
|---|---|---|---|
Action | Array of strings | Yes | Specific operation permissions on a resource.
|
Effect | string | Yes | Effect of the permission. The value can be Allow or Deny. If both Allow and Deny statements are found in a policy, the authentication starts from the Deny statements. |
Condition | Map<String,Map<String,Array<String>>> | No | Conditions for the permission to take effect. NOTE: Take the condition in the sample request as an example, the values of the condition key (obs:prefix) and string (public) must be equal (StringEquals).
|
Resource | Object | No | Cloud resource. The rules are as follows:
|
Parameter | Mandatory | Type | Description |
|---|---|---|---|
methods | Mandatory | String Array | Fill assume_role in this field. |
agency_name | Mandatory | String | Name of the agency created by a delegating party. |
domain_name or domain_id | Mandatory | String | domain.name: Name of the domain which the delegating party belongs to. |
duration_seconds | No | Int | Validity period (in seconds) of an AK/SK and security token. The value ranges from 15 minutes to 24 hours. The default value is 15 minutes. |
scope | No | Object | AK/SK and security token. If this parameter is left blank, the generated security token does not contain the scope information. You are advised to leave this parameter blank. To set the scope of the temporary AK/SK and security token, specify a project or domain.
|
Parameter | Mandatory | Type | Description |
|---|---|---|---|
methods | Mandatory | String Array | Fill token in this field. |
token | No | JSON object | Common token or federated token required for obtaining a temporary AK/SK. You need to choose either the ID in this object or X-Auth-Token in the request header. X-Auth-Token takes priority over the ID in this object. |
duration_seconds | No | Int | Validity period (in seconds) of an AK/SK and security token. The value ranges from 15 minutes to 24 hours. The default value is 15 minutes. |
{"auth": {"identity": {"methods": ["assume_role"],"assume_role": {"domain_id": "411edb4b634144f587ffc88f9bbdxxx","xrole_name": "testagency","duration_seconds": 3600}}}}
{"auth": {"identity": {"methods": ["token"],"token": {"id": "MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...","duration_seconds": 900}}}}
Parameter | Mandatory | Type | Description |
|---|---|---|---|
Mandatory | Object | Authentication information. |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
expires_at | Mandatory | String | Expiration time. |
access | Mandatory | String | AK. |
secret | Mandatory | String | SK. |
securitytoken | Mandatory | String | Used for subsequent replacement of an SK or token. |
{"credential": {"access": "NQC51NFINJS1JXX...","secret": "EY74MByPZ46kTRJL9ay5DskqXX...","expires_at": "2017-04-17T07:55:18.575000Z","securitytoken": "gAAAAABY9GbWUaGtoa9DPj7_dE4qUSnAXXX..."}}
Status Code | Description |
|---|---|
201 | The request is successful. |
400 | The server failed to process the request. |
401 | Authentication failed. |
403 | Access denied. |
500 | The system is abnormal. |