无法在钥匙斗篷中创建用户。获取 403 状态
2022-09-04 05:36:34
我正在尝试以编程方式访问在密钥保护套中创建用户。但是我得到的是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);
响应状态为 403