[英]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.