My setup has three components:
The frontend will
I finally found a solution that works well and seems to be "the Keycloak way" to issue credentials to external applications. To create a new set of credentials, add a new Keycloak client and change the following settings:
The external application will use our newly created client's name as the client_id
. The client_secret
was generated automatically and can be found under the Credentials tab.
If your Keycloak-protected services are configured to check the aud
claim of incoming Bearer tokens, a second step is necessary. By default, the audience of the JWT tokens that Keycloak issues to your client will be set to your client's name, so they will be rejected by your services. You can use Client Scopes to modify that behavior:
Keycloak will now add your service's name to the aud
claim of all JWT tokens it issues to your new client. Check out the Keycloak documentation on Service Accounts for more details.
An external application can now use its credentials to obtain an access token from Keycloak's token endpoint:
POST {keycloak-url}/auth/realms/atlas/protocol/openid-connect/token
Content-Type
header to application/x-www-form-urlencoded
grant_type=client_credentials
in the request body