In your own application, you will need to implement the OAuth2 authorization flow to obtain a bearer token.
To get a bearer token, make a POST request to the
/oauth/token
endpoint.
For example:
curl POST "https://sleephq.com/oauth/token" \
-d "client_id=my-client-id" \
-d "client_secret=my-client-secret" \
-d "grant_type=password" \
-d "scope=read write delete"
The response will be:
{
"access_token": "my-access-token",
"token_type": "Bearer",
"expires_in": 7200,
"refresh_token": "an-invalid-refresh-token",
"scope": "read write delete",
"created_at": 1752817725
}
Please note that the OAuth spec does not allow the password
grant to use refresh tokens. Even though you get a
refresh token back in the response, you will need to generate a new token each time the current token expires.
We recommend continuing to use the bearer token until you receive a 401 Unauthorized
response. The response body will be:
{
"error": "The access token expired"
}