Skip to main content

Token Authentication

From the quick start example, you can see that using the CloudTower API consists of 2 steps: first, obtain an authentication token by logging in; second, carry the token in the Authorization header and call the corresponding API to perform operations.

The token obtained in the first step does not have an expiration time and can be used indefinitely, so you only need to obtain the token once for a series of operations

Except for login, all the requests need to add the authentication field.

The CloudTower API makes authentication by passing the Authorization field in the headers. Here is how to get a token, using cURL as an example:
curl -X 'POST' \
'http://CLOUDTOWER_IP/v2/api/login' \
-H 'accept: application/json' \
-H 'content-language: en-US' \
-H 'Content-Type: application/json' \
-d '{
"username": "string",
"source": "LOCAL",
"password": "string"
}'

And here is what can be obtained:

{
"task_id": "string",
"data": {
"token": "string"
}
}

The data.token is the authentication field to be used, you can just add it to header.Authorization.

  • If called via cURL, add -H 'Authorization: token-string'.
  • If called via the swagger api documentation page, click the Authorization button and add data.token to value.