Hi Marc.
Try setting the grantType:
KeycloakBuilder builder = KeycloakBuilder.builder() //
.realm(kcRealm) //
.serverUrl(kcServerUrl)//
.clientId(kcResource) //
.clientSecret(kcClientSecret) //
.grantType(OAuth2Constants.CLIENT_CREDENTIALS);
Hth, greetings
Henning
Am Mi., 16. Jan. 2019 um 00:29 Uhr schrieb Marc Spehlmann <marc(a)autonomic.ai
:
I have tried to configure the RestEasy client to use a service
account for
one of my confidential clients. The Java code to configure the client looks
like:
```
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
class Scratch {
public static void main(String[] args) {
final String server = "localhost:8082";
final String realm = "master";
final String clientSecret = "00000000-0000-0000-0000-000000000000";
final String clientId = "MyClient";
Keycloak keycloak = KeycloakBuilder.builder()
.serverUrl(server)
.realm(realm)
.clientId(clientId)
.clientSecret(clientSecret)
.build();
keycloak.realm("master")
.clients()
.findAll();
}
}
```
This will fail with the exception:
```
Exception in thread "main" java.lang.IllegalStateException: username
required
at
org.keycloak.admin.client.KeycloakBuilder.build(KeycloakBuilder.java:131)
at Scratch.main(scratch_41.java:17)
```
I have a workaround, but my question is, is there any plan to support
service-accounts with the keycloak client?
_______________________________________________
keycloak-user mailing list
keycloak-user(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user
--
Henning Waack | IT Consultant
codecentric AG | Hochstraße 11
<
https://maps.google.com/?q=Hochstra%C3%9Fe+11%C2%A0+%7C+%C2%A0+42697+Soli...
|
<
https://maps.google.com/?q=Hochstra%C3%9Fe+11%C2%A0+%7C+%C2%A0+42697+Soli...
<
https://maps.google.com/?q=Hochstra%C3%9Fe+11%C2%A0+%7C+%C2%A0+42697+Soli...
Solingen
<
https://maps.google.com/?q=Hochstra%C3%9Fe+11%C2%A0+%7C+%C2%A0+42697+Soli...
|Deutschland
<
https://maps.google.com/?q=Hochstra%C3%9Fe+11%C2%A0+%7C+%C2%A0+42697+Soli...
tel: +49 (0)151 108 515 29
www.codecentric.de | blog.codecentric.de |
www.meettheexperts.de
Sitz der Gesellschaft: Solingen | HRB 25917 | Amtsgericht Wuppertal
Vorstand: Michael Hochgürtel . Ulrich Kühn . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen Schütz
Diese E-Mail einschließlich evtl. beigefügter Dateien enthält vertrauliche
und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige
Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie
bitte sofort den Absender und löschen Sie diese E-Mail und evtl.
beigefügter Dateien umgehend. Das unerlaubte Kopieren, Nutzen oder Öffnen
evtl. beigefügter Dateien sowie die unbefugte Weitergabe dieser E-Mail ist
nicht gestattet.