Authentication
eClear uses bearer tokens for authentication. You need to pass this token to every request that you make. You can get a JSON Web Token (JWT) by making the following request:
POST https://eclear-solutions.com/api/auth/v1/login HTTP/1.1
Content-Type: application/json
{
"username": "{{username}}",
"password": "{{password}}"
}The response contains the access_token and refresh_token. You can use the refresh_token to refresh your token if it expires (after 5 minutes):
POST https://eclear-solutions.com/api/auth/v1/refresh HTTP/1.1
Content-Type: application/json
{
"refreshToken": "{{refresh_token}}"
}The refresh token has a lifetime of 30 minutes. If you write a client program then you would typically use the access token for as long as you encounter a 401 status code. Upon encountering the 401 error you would refresh the token.
Once you have an access token you need to pass it as the value of the Authorization header. For example, to retrieve information about your user you
would make the following request:
GET https://eclear-solutions.com/api/auth/v1/me HTTP/1.1
Content-Type: application/json
Authorization: Bearer {{access_token}}