Obtaining an access token

Content Software for File CLI Reference

Version
4.2.x
Audience
anonymous
Part Number
MK-HCSF001-03

You must provide an access token to use the Content Software for File REST API.

To obtain access/refresh tokens via the CLI, refer to Obtaining an authentication token (there you can also generate an access token with a longer expiry time). To obtain access/refresh tokens via the API, you can call the login API, providing it a username and password.

If you already obtained a refresh token, you can use the login/refresh API to refresh the access token.

Python example calling the login API

import requests
url = "https://weka01:14000/api/v2/login"
payload="{\n    \"username\": \"admin\",\n    \"password\": \"admin\"\n}"
headers = {
  'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

In response, you will get an access token (valid for 5 minutes), that can be used in the other APIs that require token authentication, along with the refresh token (valid for 1 year), for getting additional access tokens without using the username/password.

Login/Refresh Response

{
   "access_token": "ACCESS-TOKEN",
   "token_type": "Bearer",
   "expires_in": 300,
   "refresh_token": "REFRESH-TOKEN"
    }
  ]
}