Authentication
Hausing uses OAuth 2.0 Bearer tokens for authentication. Machine-to-machine authentication is done with OpenID Connect (OIDC).
Prerequisites
Section titled “Prerequisites”- Client ID and Client Secret — please contact support to obtain these
Obtaining an access token
Section titled “Obtaining an access token”Use a POST request to the token endpoint to obtain an authentication token.
Parameters:
grant_type— use the stringclient_credentialsas valueclient_id— obtained from Hausing supportclient_secret— obtained from Hausing support
Example:
curl -X POST 'https://keycloak.prod.hausing.ee/realms/Hausing/protocol/openid-connect/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=client_credentials' \ --data-urlencode 'client_id=unique-id' \ --data-urlencode 'client_secret=super-secret-random-string'Response:
{ "access_token": "jwt.token.value", "expires_in": 300, "refresh_expires_in": 0, "token_type": "Bearer", "not-before-policy": 1637159808, "scope": "profile email contracts"}Use the access_token from the response to authenticate all Hausing REST API requests.