我正在尝试以编程方式访问在 keycloak 中创建用户。但我得到 403 作为状态码。我正在关注以下链接。
https://technology.first8.nl/programmatically-adding-users-in-keycloak/
谁能帮我?提前致谢
我使用以下代码创建用户
Keycloak kc = Keycloak.getInstance(
"http://{server name}:8080/auth",
"{realm name}", // the realm to log in to
"{useraname}",
"{password}", // the user
"{client id}",
"{client secret key}");
CredentialRepresentation credential = new CredentialRepresentation();
credential.setType(CredentialRepresentation.PASSWORD);
credential.setValue("test123");
UserRepresentation user = new UserRepresentation();
user.setUsername("codeuser");
user.setFirstName("sampleuser1");
user.setLastName("password");
user.setCredentials(Arrays.asList(credential));
user.setEnabled(true);
Response result = kc.realm("{realm name}").users().create(user);
response.status 以 403 的形式出现