Obtaining a Token
A token is an access credential issued to an IAM user to bear the user's identity and permissions. The validity period of a token is 24 hours. Cache the token to prevent frequent API calling. The original token will be valid till it expires regardless of whether a new token has been obtained. Ensure that the token is valid when you use it. Using a token that will soon expire may cause API calling failures. You can obtain a token using any of the following methods:
Debugging an API in API Explorer
Set parameters on the page of an IAM API on API Explorer, and click Debug. The value of X-Subject-Token in Response is a token.
Using Postman
Use Postman to obtain a token. If 201 is returned after you send a request, click Header. The value of X-Subject-Token is a token.
Using KooCLI
hcloud IAM KeystoneCreateUserTokenByPassword --cli-region=${regionName} --auth.identity.methods.1="password" --auth.identity.password.user.name=${IAM user name} --auth.identity.password.user.password=${IAM user password} --auth.identity.password.user.domain.name=${Name of the account to which the IAM user belongs} --auth.scope.domain.name=${Name of the account to which the IAM user belongs} --cli-output=tsv --cli-query="response_header.X-Subject-Token[0]"
If the invocation is successful, the returned result is a token.
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