Token-based Authentication
Application Scenario
For token-based authentication, you must obtain your token and add X-Auth-Token to the headers of API requests.
This section describes how to authorize API requests using tokens. For details about how to obtain a token, see Obtaining a User Token Through Password Authentication.
Procedure
- Send POST https://Endpoint of IAM/v3/auth/tokens to obtain the endpoint of Identity and Access Management (IAM) and the region name in the message body. For details, see Endpoints of IAM.
Table 1 Endpoints of IAM Service Name
Region Name
Region
Endpoint
Protocol
IAM
CN North-Beijng1
cn-north-1
iam.cn-north-1.myhuaweicloud.com
HTTPS
CN South-Guangzhou
cn-south-1
iam.cn-south-1.myhuaweicloud.com
HTTPS
CN East-Shanghai2
cn-east-2
iam.cn-east-2.myhuaweicloud.com
HTTPS
CN Northeast-Dalian
cn-northeast-1
iam.cn-northeast-1.myhuaweicloud.com
HTTPS
All
ALL
iam.myhuaweicloud.com
HTTPS
CN-Hong Kong
ap-southeast-1
iam.ap-southeast-1.myhuaweicloud.com
HTTPS
Example request:{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username",//Replace the username as required. "password": "password",//Replace the password as required. "domain": { "name": "domainname"//Replace the domainname as required. } } } }, "scope": { "project": { "name": "cn-north-1" //cn-north-1 indicates an IAM region. Replace it as required. } } } } - Obtain a token. After a response is returned, the value of X-Subject-Token in the response header is the token value.
- Call a service API and add X-Auth-Token to the request header. The value of X-Auth-Token is the token value obtained in 2.
Last Article: Calling APIs
Next Article: Constructing Requests
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.