Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Identity and Access Management/ API Reference/ API/ Access Key Management/ Obtaining Temporary Access Keys and Security Tokens of a Federated User

Obtaining Temporary Access Keys and Security Tokens of a Federated User

Updated on 2024-11-18 GMT+08:00

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

Table 1 Parameters in the request header

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).

Table 2 Parameters in the request body

Parameter

Mandatory

Type

Description

auth

Yes

Object

Authentication information.

Table 3 auth

Parameter

Mandatory

Type

Description

identity

Yes

Object

Authentication parameters.

Table 4 auth.identity

Parameter

Mandatory

Type

Description

methods

Yes

Array of strings

Authentication method. The value of this parameter is ["token"].

token

No

Object

Validity period of temporary access keys and security tokens.

policy

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.

Table 5 auth.identity.policy

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.

Statement

Yes

Array of objects

Statement of the policy.

Table 6 auth.identity.policy.Statement

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:
  • Format: Service name:Resource type:Action, for example, vpc:ports:create
  • Service name: indicates the product name, such as ecs, evs, or vpc. Only lowercase letters are allowed. Resource types and actions are not case-sensitive. You can use an asterisk (*) to represent all actions.

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:

  • Allow
  • Deny

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:
  • Format: Service name:Region:Domain ID:Resource type:Resource path. Wildcard characters (*) are supported. For example, obs:*:*:bucket:* indicates all OBS buckets. For details about cloud services that support resource-level authorization, see Cloud Services that Support Resource-Level Authorization Using IAM.
  • The region segment can be * or a region accessible to the user. The specified resource must belong to the corresponding service that actually exists.
  • The service name, region, domain ID, and resource type can be 1 to 50 characters long, including letters, digits, underscores (_), hyphens (-), and asterisks (*). The resource path can be 1 to 1200 characters long, excluding semicolons (;), vertical bars (|), tildes (~), backquote (`), curly brackets ({}), square brackets ([]), and angle brackets (<>).
Table 7 auth.identity.token

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

Table 8 Parameters in the response body

Parameter

Type

Description

credential

Object

Authentication result.

Table 9 credential

Parameter

Type

Description

expires_at

String

Expiration time of access keys and security tokens. The response is UTC time.

access

String

AK.

secret

String

SK.

securitytoken

String

Obtained access keys in ciphertext.

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

Kami menggunakan cookie untuk meningkatkan kualitas situs kami dan pengalaman Anda. Dengan melanjutkan penelusuran di situs kami berarti Anda menerima kebijakan cookie kami. Cari tahu selengkapnya

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback