Help Center/ FunctionGraph/ FAQs/ General FAQs/ How Do I Obtain a Token?
Updated on 2022-08-19 GMT+08:00

How Do I Obtain a Token?

You can use a token for authentication when calling APIs. To obtain a token, use the standard API of Identity and Access Management (IAM).

  • Run the following command to obtain the token in the CN South-Guangzhou region:
    curl -k -i  -X POST   https://iam.cn-south-1.myhuaweicloud.com/v3/auth/tokens  -H 'Content-Type: application/json'  -d '{
      "auth": {
        "identity": {
          "methods": [
            "password"
          ],
          "password": {
            "user": {
              "name": "HUAWEI CLOUD account",
              "password": "Login password",
              "domain": {
                 "name": "HUAWEI CLOUD account"
              }
            }
          }
        },
        "scope": {
          "project": {
            "name": "cn-south-1"
          }
        }
      }
    }'
  • Run the following command to obtain the token in the CN North-Beijing1 region:
    curl -k -i  -X POST   https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens  -H 'Content-Type: application/json'  -d '{
      "auth": {
        "identity": {
          "methods": [
            "password"
          ],
          "password": {
            "user": {
              "name": "HUAWEI CLOUD account",
              "password": "Login password",
              "domain": {
                "name": "HUAWEI CLOUD account"
              }
            }
          }
        },
        "scope": {
          "project": {
            "name": "cn-north-1"
          }
        }
      }
    }'

    The value of X-Subject-Token in the response header is the token. A token obtained in one region can only be used to call FunctionGraph in this region.

    For details, see Obtaining a User Token.