Updated on 2024-04-09 GMT+08:00

Obtaining a Token

Application Scenarios

If you use a token for authentication, you must obtain the token and add X-Auth-Token to the request header of the API when making a call.

Authenticating the Token

  1. Send POST https://IAM endpoint/v3/auth/tokens. Obtain the Identity and Access Management (IAM) endpoint and region name in the message body.

    See .

    See Regions and Endpoints.

    The following is an example request:

    The italic words in the following example need to be replaced with the actual values. For details, see the Identity and Access Management API Reference.

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

  2. Obtain the token. The token is the value of X-Subject-Token in the response.
  3. Call a service API, add X-Auth-Token to the request header, and set the value of X-Auth-Token to the token obtained in 2.