Updated on 2026-11-06 GMT+08:00

Authentication

API calls support token-based authentication.

Token-based Authentication

A token specifies temporary permissions in a computer system. During API authentication using a token, the token is added to requests to get permissions for calling the API.

  • The validity period of a token is 24 hours. When using a token for authentication, cache it to prevent frequently API calling.
  • Ensure that the token is valid when you use it. Using a token that will soon expire may cause API calling failures.

The token can be obtained by calling the API for obtaining a user token through password authentication. A project-level token is required for calling this service API, that is, when calling the API for obtaining a user token through password authentication, set the value of auth.scope in the request body to project.

{ 
    "auth": { 
        "identity": { 
            "methods": [ 
                "password" 
            ], 
            "password": { 
                "user": { 
                    "name": "username", 
                    "password": "********", 
                    "domain": { 
                        "name": "domainname" 
                    } 
                } 
            } 
        }, 
        "scope": { 
            "project": { 
                "name": "xxxxxxxx" 
            } 
        } 
    } 
}

After a token is obtained, the X-Auth-Token header field must be added to requests to specify the token when calling other APIs. If the token is ABCDEFG...., add X-Auth-Token: ABCDEFG.... to a request. For example:

POST https://iam.ap-southeast-1.myhuaweicloud.com/v3.0/OS-USER/users 
Content-Type: application/json 
X-Auth-Token: ABCDEFG....