Run
docker-compose upto spin up Keycloak.
-
Go to http://localhost:8888. Use default credentials (admin/admin) to log in.
-
Go to Clients -> Create Client and start filling fields as follows.

-
Click "Next" and on "Capability config" page enable "Client Authentication" and click "Next".
-
And click "Save"
-
Open newly created Client "cfg-mgmt" and go to "Roles" tab. Create new role "ConfigAdmin".
-
Now switch to "Credentials" tab and copy "Client Secret". It will be needed for IDP configuration in ai-dial-admin-backend.
-
Click create and go to "Credentials" tab. Set the password for that user and set "Temporary" flag to false
-
Go to "Role Mapping" and click "Assign role". Search for "ConfgiAdmin" role created before. Assign selected role.
-
Now go to ai-dial-admin-backend application.properties and configure Identity Provider as follows:
- application.properties
config.rest.security.mode=oidc- environment variables
providers.keycloak.issuer=http://localhost:8888/realms/master
providers.keycloak.jwk-set-uri=http://localhost:8888/realms/master/protocol/openid-connect/certs
providers.keycloak.audiences=account
providers.keycloak.role-claims=resource_access.*.rolesTo use configured IDP with Sample HTTP Client located here you need to set env variables
Replace {client_secret} with client secret that you copied from "Client Secret" tab
{
"dev": {
"Security": {
"Auth": {
"keycloak": {
"Type": "OAuth2",
"Grant Type": "Authorization Code",
"Client ID": "cfg-mgmt",
"Redirect URL": "http://localhost:3000",
"Auth URL": "http://localhost:8888/realms/master/protocol/openid-connect/auth",
"Token URL": "http://localhost:8888/realms/master/protocol/openid-connect/token",
"Client Secret":"{client_secret}"
}
}
}
}
}Now you are ready to user Authorization based on JWT token. Well done!
To easily obtain tokens from Keycloak for testing or troubleshooting, you can use the provided Postman collection: docs/sample/http-requests/Keycloak.postman_collection.json.
Follow these steps:
-
Configure Environment Variables
Set theKEYCLOAK_HOSTandREALMvariables in your Postman environment to match your Keycloak instance. -
Initiate the Authorization Flow
Open theauthrequest from the Postman collection in your browser. Complete the authentication process as prompted. -
Retrieve the Authorization Code
After successful authentication, you will be redirected. Copy thecodeparameter from your browser's address bar. -
Set Up the Token Request
- Paste the copied
codevalue into theAUTH_CODEvariable in thetokenrequest within Postman. - Set the
KEYCLOAK_SECRET_DIAL_ADMINvariable to the client secret you obtained from the Keycloak admin console.
- Paste the copied
-
Request the Token
Execute thetokenrequest in Postman. You should receive an access token in the response.
Note on PKCE (Proof Key for Code Exchange):
If your client is configured to use PKCE, the authorization request may require two additional parameters:code_challengeandcode_challenge_method.
- You can generate a
code_verifierand its correspondingcode_challengeusing an online tool such as PKCE Generator.- During the authorization request, include the generated
code_challengeandcode_challenge_methodparameters.- When making the token request, include the original
code_verifierparameter.- These PKCE-related parameters are available as optional fields in the provided Postman collection.
This process will help you quickly obtain and test JWT tokens from your Keycloak setup.

