[英]Keycloak add custom attributes to user through confidential client
我正在尝试使用 Java SDK 向用户添加自定义属性,但收到400 Bad Request 。 这是我的代码:
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);
更新像first name
这样的标准属性虽然有效,但除了管理用户之外,我还需要其他一些帐户服务角色吗?我想我已经全部尝试过了。
结果发现其中一个属性值太长了。 通过读取 Keycloak 服务器的日志找到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.