1

I have a scenario wherein there are multiple apps/service that need to access my Resource:

These are the three external services: service1, service2, service3.

Now I am using the client_credentials grant type for this since this is machine to machine and no user is involved.

What I did is to create 1 client for each service in Keycloak. It works fine, however I need to add some more details in the token, in particular, a human readable name for each client as the client id is named using the recommended naming.

I know how to map user claims to the token, but is it possible to have something similar for my scenario wherein there are no users and I only have the clients?

Aaron
  • 2,591
  • 4
  • 27
  • 45

1 Answers1

1

Yes, go to the Realm of your app, then:

  • Go to Clients;
  • Select your client;
  • Select Mappers;
  • click on the button [Create];
  • select Hardcoded Claim as Mapper Type;
  • fill up the details of the claim

Click [Save].

dreamcrash
  • 47,137
  • 25
  • 94
  • 117
  • is there a dynamic way for this? something like providing a header eg 'claims' when requesting the client_credentials grant Token, and then keycloak adding these to the token payload? – eja Apr 26 '22 at 14:57
  • @eja Yep, have a look a this one https://stackoverflow.com/questions/71247870/correct-way-to-customize-keycloak-access-token-with-scenario-where-were-using-a/71249185#71249185 – dreamcrash Apr 26 '22 at 19:27