I'm using Keycloak's Java keycloak-admin-client
and I'm wanting to set up some protocol mappers for my realm's client.
The Java API exposes this class to create a protocol mapper and then the following method to set the config options:
ProtocolMapperRepresentation protocolMapperRep = new ProtocolMapperRepresentation();
protocolMapperRep.setConfig(Map.of("some.mapper.config.option", "mapper-value"));
I've looked at the javadoc documentation and it's, well, completely useless unfortunately. :( I have not looked at the rest-api documentation, but I just looked at it and it doesn't do anything to enumerate the config options for the protocol mapper representation: https://www.keycloak.org/docs-api/12.0/rest-api/index.html#_protocolmapperrepresentation
I saw a few options from another StackOverflow question here: Add protocol-mapper to keycloak using kcadm.sh
However, there has to be a better place where these are documented.
Typically, what you can do is to first look at Rest API Documentation and the Keycloak API.
Alternatively, and this almost always work, you just create the protocol Mapper using the Keycloak Admin API, for instance:
Then before clicking Save
, open your browser developer network console and look at the network requests. Then click save
:
You will have two post request, one for the token, another for the creation of the mapper:
Look at the request payload, you will see something as:
{
"protocol": "openid-connect",
"config": {
"multivalued": "true",
"id.token.claim": "true",
"access.token.claim": "true",
"userinfo.token.claim": "true",
"claim.name": "asdas"
},
"name": "asdas",
"protocolMapper": "oidc-usermodel-realm-role-mapper"
}
Now you can infer the options from there. Not ideal I know.