Obtaining an Access Credential
Function
This API is used to obtain the application API access credential. A token is valid for 30 minutes by default. You can configure the validity period in "Administrator Portal" > "Settings" > "Service Settings" > "API Authentication". Cache your token to prevent frequent API calling. Ensure that the token is valid while you use it. Using a token that will soon expire may cause API calling failures. Obtaining a new token does not affect the validity of the existing token.
Constraints
null
URI
POST /api/v2/tenant/token
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
grant_type |
Yes |
String |
Grant type. The value is fixed at client_credentials. |
client_id |
Yes |
String |
Application ID, which is a client ID allocated to an application after registration. |
client_secret |
Yes |
String |
Application secret, which is a client secret allocated to an application after registration. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
access_token |
String |
Authentication credential, which is used to call management APIs. |
token_type |
String |
Authentication credential type. This value is fixed at Bearer. |
expires_in |
Integer |
Time when the token will expire. Unit: second. Default value: 1,800. |
scope |
String |
Authorization scope of the obtained access token. |
id_token |
String |
Authorized access ID token. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error details. |
Example Requests
Obtain the credential, namely, the API authentication token, by using the application client ID and client secret.
POST https://{domain_name}/api/v2/tenant/token Content-Type: application/x-www-form-urlencoded client_id=ONtQq2igSggfFClyGgzmuXR8ubWEP...& client_secret=XdqUmJpG19hNEHz3472XsPcwvfe...& grant_type=client_credentials
Example Responses
Status code: 200
Request successful.
{ "access_token" : "334******140", "token_type" : "Bearer", "expires_in" : 1719, "scope" : "all", "id_token" : "ey******Is.ey******Yo.EL******YW" }
Status Codes
Status Code |
Description |
---|---|
200 |
Request successful. |
400 |
Invalid parameter. |
Error Codes
See Error Codes.
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