Obtaining a Token
When any ELB API is called, you need to call the interface of Identity and Access Management (IAM) to authenticate the request.
Procedure
- Create environment variables. On the homepage of Postman, click the environment variable management button (the gear icon in the following figure). Create a group of variables named huaweicloud.com. The keys must contain a least username, password, domain_username, and project_id. Then, set the values. You can obtain the values from My Credentials page on the web console.
Figure 1 Environment variable management
Figure 2 Setting environment variable values
The variables in the preceding figure can be found from the My Credentials page on the web console. The following table lists the mapping between attributes on the web console and variables.
Table 1 Variables Variable
Description
username
Username
password
Password
tenant_id
User ID
domain_username
Account name
domain_id
Account ID
project_id
Project ID
region
Region
X-Auth-Token
Tenant's token
- Set the request body.

Select the raw format and select JSON (application/json) on the right.
For details, see the Identity and Access Management API Reference.
- Send the request.
Enter the requested URL in the address box. Send the request to the public IAM backend address of all sites, and add the URI (/v3/auth/tokens) to it.
Select the POST request method and click Send. If the preceding information is correct, a response similar to the following is displayed.

On the Headers page, the value of x-subject-token is the token required for sending the request.

When calling ELB APIs, add the X-Auth-Token field to the request header and set its value to the obtained token. If 401 Unauthorized is returned, check whether the information in the request body is correct.
Sample Code
Request body in 2
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "{{username}}",
"password": "{{password}}",
"domain": {
"name": "{{domain_username}}"
}
}
}
},
"scope": {
"project": {
"id": "{{project_id}}"
}
}
}
}
In the request body, fields in {{ }} are reference variables.
Last Article: Getting Started
Next Article: Creating a Load Balancer
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.