I am using Keycloak v25.
The caller will set “audence” in the token request.
grant_type: "client_credentials"
client_id: "my-client-1"
client_secret: "<client secret>"
audience: "https://myapi.example.com"
How do I get the audience value into “aud” of the resulting JWT token, for example
{
"exp": 1718809393,
"iat": 1718809093,
"jti": "3813a93e-47b1-468d-aa4c-47c236462ce7",
"iss": "http://localhost:18080/realms/MyKeycloak",
"sub": "2f605b7b-4a27-467a-a090-bc3de1102873",
"aud": "https://myapi.example.com",
"typ": "Bearer",
"scope": "",
...
}
I tried adding a Client Scope which has “Audenice” mapping. But it is showing
{
"exp": 1718809393,
"iat": 1718809093,
"jti": "3813a93e-47b1-468d-aa4c-47c236462ce7",
"iss": "http://localhost:18080/realms/MyKeycloak",
"sub": "2f605b7b-4a27-467a-a090-bc3de1102873",
"aud": "c93ad476-7d19-41cf-b766-50065391aeae", <-- Random generated value
"typ": "Bearer",
"scope": "",
...