Authorization via curl

You can get authorize code via curl using password grant type.

Example

bash
curl "https://api-dev.lifepeaks.dk/token" \
  -d 'client_id={clientId}&client_secret={clientSecret}&grant_type=password&username={apiUserUsername}&password={apiUserPassword}'

Response example:

json
{
  "access_token": "413cf40b7c3e2f05d329ed3577441c2311366497",
  "expires_in": 86400,
  "token_type": "Bearer",
  "scope": "admin",
  "refresh_token": "e01008fda47a4fd2ac17eccb9dcef62187372266"
}

Refreshing the token

When the access token expires after 24 hours, exchange the refresh token rather than sending the credentials again. A new refresh token is issued each time, so store the one from the latest response.

bash
curl "https://api-dev.lifepeaks.dk/token" \
  -d 'client_id={clientId}&client_secret={clientSecret}&grant_type=refresh_token&refresh_token={refreshToken}'

FAQ

Q: I have incorrect credentials. Error is saying "Invalid username and password combination".

A: Ensure values in request are encoded. For testing you can use service like https://www.urlencoder.org/.

Q: Auth request returns error on my GET request.

A: Auth request is accepting POST requests.