[英]Keycloak add custom attributes to user through confidential client
I'm trying to add custom attributes to a user using the Java SDK but receive a 400 Bad Request .我正在尝试使用 Java SDK 向用户添加自定义属性,但收到400 Bad Request 。 Here's my code:这是我的代码:
UserResource userResource = usersResource.get(userId);
UserRepresentation user = userResource.toRepresentation();
Map<String, List<String>> attributes = user.getAttributes() != null
? user.getAttributes() : new HashMap<>();
attributes.put("attribute1", List.of("value1"));
attributes.put("attribute2", List.of("value2"));
attributes.put("attribute3", List.of("value3"));
user.setAttributes(attributes);
userResource.update(user);
Updating standard attributes like first name
work though, is there some other Account Service Role I need than manage users, I think I've tried them all..更新像first name
这样的标准属性虽然有效,但除了管理用户之外,我还需要其他一些帐户服务角色吗?我想我已经全部尝试过了。
Turns out that one of the attribute values were too long.结果发现其中一个属性值太长了。 Found it by reading the logs from Keycloak server.通过读取 Keycloak 服务器的日志找到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.