Authentication¶
To retrieve your access_token
you’ll need to send a POST
to your KeyCloak instance at https://keycloak-ID.ab.contegix.com.
-
POST
/auth/realms/contegix/protocol/openid-connect/token
¶ Fetch bearer token
Status Codes: - 200 OK – Bearer token
- 401 Unauthorized – Invalid user credentials
In the body of your POST
request, you’ll want to include x-www-form-urlencoded
params grant_type
and client_id
as well as your username
and password
.
Sample POST
request body:
{
"username": "jdoe",
"password": "abc123",
"grant_type": "password",
"client_id" "ab-portal"
}
You’ll receive a response that contains the access_token
which can be used as a Bearer
token for further requests.
Sample response:
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5...",
"expires_in": 900,
"refresh_expires_in": 900,
"refresh_token": "eyJhbGciOiJSUzI1NiIsInR5...",
"token_type": "bearer",
"not-before-policy": 0,
"session_state": "a2eb241b-b130-4f02-8de1-10f5ffb70909"
}
With your access_token
set the following header for future API requests.
Authorization: Bearer <access_token_value>
You can preserve and refresh your session without needing to reauthenticate by sending the refresh_token
from above to the same POST
endpoint like so:
{
"refresh_token": "eyJhbGciOiJSUzI1NiIsInR5...",
"grant_type": "refresh_token",
"client_id": "ab-portal"
}