Obtaining Temporary Access Keys and Security Tokens of a Federated User
Function
This API is used to obtain temporary access keys and security tokens through a token. Temporary access keys and security tokens are issued by the system to IAM users, and can be valid for 15 minutes to 24 hours. Temporary access keys and security tokens are granted permissions based on the principle of least privilege (PoLP).
The API can be called using either a global endpoint or a region-specific endpoint. For IAM endpoints, see Regions and Endpoints.
Temporary access keys and security tokens must be used together, and the x-security-token field must be included in the request header. For details, see How Do I Use a Temporary AK/SK to Sign Requests?
Debugging
You can debug this API in API Explorer.
URI
POST /v3.0/OS-CREDENTIAL/securitytokens
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Fill application/json;charset=utf8 in this field. |
X-Auth-Token |
Yes |
String |
Used to obtain security tokens (federated users can only use X-Auth-Token to obtain security tokens). |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Yes |
Object |
Authentication information. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
methods |
Yes |
Array of strings |
Authentication method. The value of this parameter is ["token"]. |
No |
Object |
Validity period of temporary access keys and security tokens. |
|
No |
Object |
Custom policy that defines the permissions assigned to the temporary access keys and security tokens (currently, the policy only applies to OBS). If this parameter is specified, the permissions assigned to the temporary access keys and security tokens are the intersection of permissions assigned to the original token and defined by this parameter. The value of policy can contain a maximum of 2,048 characters. For details about the format and grammar of IAM policies, see Policies. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Version |
Yes |
String |
Policy version. When creating a custom policy, set this parameter to 1.1.
NOTE:
1.1: Policy. A policy defines the permissions required to perform actions on a specific cloud resource under certain conditions. |
Yes |
Array of objects |
Statement of the policy. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Action |
Yes |
Array of strings |
Specific permissions on a resource. For details about supported actions, see "Permissions and Supported Actions" in the API Reference of cloud services.
NOTE:
|
Effect |
Yes |
String |
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. Options:
|
Condition |
No |
Map<String,Map<String,Array<String>>> |
Conditions for the permissions to take effect. For details about conditions, see Policy Grammar.
NOTE:
In the following request example, the policy is in effect only when DomainName is set to DomainNameExample. "Condition": { "StringEquals": { "g:DomainName": [ "DomainNameExample" ] } } |
Resource |
No |
Array of strings |
Cloud resource.
NOTE:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
No |
String |
Token. This parameter is mandatory if X-Auth-Token is not specified in the request header. |
duration_seconds |
No |
Integer |
Validity period (in seconds) of temporary access keys and security tokens. The value range is from 15 minutes to 24 hours. The default value is 15 minutes. |
Response Parameters
Parameter |
Type |
Description |
---|---|---|
Object |
Authentication result. |
Example Request
- Request with token specified (including the token ID and the validity period of temporary access keys and security tokens)
POST https://iam.myhuaweicloud.com/v3.0/OS-CREDENTIAL/securitytokens
{ "auth": { "identity": { "methods": [ "token" ], "token": { "id": "MIIEIgYJKoZIhvc...", "duration_seconds": "900" } } } }
- Request with the X-Auth-Token header but without the token parameter
POST https://iam.myhuaweicloud.com/v3.0/OS-CREDENTIAL/securitytokens
{ "auth": { "identity": { "methods": [ "token" ] } } }
- Request with policy specified to define the permissions assigned to the obtained temporary access keys and security tokens (currently, the policy applies only to OBS). If this parameter is specified, the permissions assigned to the temporary access keys and security tokens are the intersection of permissions assigned to the original token and defined by this parameter.
POST https://iam.myhuaweicloud.com/v3.0/OS-CREDENTIAL/securitytokens
{ "auth": { "identity": { "methods": [ "token" ], "policy": { "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "obs:object:GetObject" ], "Resource": [ "OBS:*:*:object:*" ], "Condition": { "StringEquals": { "g:DomainName": [ "DomainNameExample" //Example condition value. Replace it with the actual value. ] } } } ] }, "token": { "duration_seconds": 900 } } } }
Example Response
Status code: 201
The request is successful.
{ "credential": { "access": "NZFAT5VNWEJDGZ4PZ...", "expires_at": "2020-01-08T03:50:07.574000Z", "secret": "riEoWsy3qO0BvgwfkoLVgCUvzgpjBBcvdq...", "securitytoken": "gQpjbi1ub3J0aC00jD4Ej..." } }
Status Codes
Status Code |
Description |
---|---|
201 |
The request is successful. |
400 |
Invalid parameters. |
401 |
Authentication failed. |
403 |
Access denied. |
500 |
Internal server error. |
Error Codes
None
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