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 Endpoint of IAM.
Table 1 Endpoint of IAM Service Name
Region Name
Region
Endpoint
Protocol
IAM
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": "ap-southeast-1" //ap-southeast-1 indicates the 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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot