Token Authentication
Scenarios
To use token authentication, you need to obtain a token and add X-Auth-Token to the request header when making API calls.
You can use either of the following authentication modes to call APIs.
- Token authentication: Requests are authenticated using a token.
- AK/SK authentication: Requests are encrypted using an AK/SK.
Calling an API Through Token Authentication
- Obtain a token.
For details, see "Obtaining a User Token" in the Identity and Access Management (IAM) API Reference.
The token is the value of X-Subject-Token in the response.
The following is an example request:
POST https://{iam_endpoint}/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "********", "domain": { "name": "domainname" } } } }, "scope": { "project": { "id": "xxxxxxxx" } } } }
In the preceding command:
- For details about {iam_endpoint}, see Regions and Endpoints.
- username indicates the username.
- domainname indicates the account name of the user.
- ******** indicates the login password of the user.
- xxxxxxxx indicates the project ID.
On the management console, click the username in the upper right corner, choose My Credentials from the drop-down list, and then view the project ID.
- To call a service API, add X-Auth-Token to the request header. The value of X-Auth-Token is that of the token obtained in 1.
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