[keycloak-user] NPE problem with admin-cli Java client
Tero Ahonen
tahonen at redhat.com
Mon Oct 14 13:35:38 EDT 2019
Hi,
I have Java code running on Wildfly 16 that uses Keycloak admin-cli java library to interact with Keycloak. Code works fine from command line, it works fine when use thru REST interface. But it doesn’t work when used from @Scheduled EJB ….
Code is really simple
Keycloak kc = KeycloakBuilder.builder()
.serverUrl(“foo")
.realm(“bar")
.grantType(OAuth2Constants.PASSWORD)
.clientId(“foo")
.username(“bar")
.password(“foo")
.build();
List<UserRepresentation> users =
kc.realm(“realm").users().search(email, 0, 1);
This fails to code
https://github.com/keycloak/keycloak/blob/e6a274ea0e31c6572e795f3372f006c88122539b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/BearerAuthFilter.java#L53 <https://github.com/keycloak/keycloak/blob/e6a274ea0e31c6572e795f3372f006c88122539b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/BearerAuthFilter.java#L53>
It seems that that token string is empty
kc.getTokenManager() is not null
kc.getTokenManager().getAccessToken() is not null
kc.getTokenManager().getAccessTokenString() IS NULL
Br,
Tero
More information about the keycloak-user
mailing list