⚠️
You are viewing the documentation for Rhize v3.2.1. View the latest.
Get Keycloak Token
When build applications on Rhize, your clients to need authenticate requests. To do that, they need to periodically request a bearer token from the Keycloak service.
Get token
With grant_type set for client credentials, you can get a bearer token with the following request:
curl -X POST "https://<KEYCLOAK_HOST>/realms/<REALM_NAME>/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=<CLIENT_ID>" \
-d "client_secret=<CLIENT_SECRET>"If the grant_type is set for password authentication the request will also require a username and password:
curl -X POST "https://<KEYCLOAK_HOST>/realms/<REALM_NAME>/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=<CLIENT_ID>" \
-d "client_secret=<CLIENT_SECRET>" \
-d "username=<USERNAME>" \
-d "password=<PASSWORD>"Response
An example response returns a JSON object with the following structure.
The access_token property has the token value.
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldU...",
"expires_in": 300,
"token_type": "Bearer",
"scope": "email profile"
}