[精讚] [會員登入]
222

keycloak 透過java client lib新增user

使用keycloak-admin-client lib maven <dependency> <gro

分享此文連結 //n.sfs.tw/15093

分享連結 keycloak 透過java client lib新增user@igogo
(文章歡迎轉載,務必尊重版權註明連結來源)
最後編修
2021-05-10 08:48:34 By igogo
 

 

 

使用keycloak-admin-client lib

 

maven

	<dependency>
			<groupId>org.keycloak</groupId>
			<artifactId>keycloak-admin-client</artifactId>
			<version>12.0.4</version>
	</dependency>

 

 

 

    Keycloak keycloak = Keycloak.getInstance(keycloakserverurl, "master", "admin", "PASSWORD", "demoapp");
        RealmRepresentation realm = keycloak.realm("master").toRepresentation() ;
//          create a user
        UserRepresentation userRepresentation = new UserRepresentation();
        userRepresentation.setUsername("ccc");
        userRepresentation.setFirstName("first name");
        userRepresentation.setEmail("ddd@ccc");
//        userRepresentation.setRequiredActions(Collections.emptyList());
        userRepresentation.setEnabled(true);

        CredentialRepresentation credentialRepresentation = new CredentialRepresentation();
        credentialRepresentation.setType(CredentialRepresentation.PASSWORD);
        credentialRepresentation.setValue("1234");

        userRepresentation.setCredentials(Collections.singletonList(credentialRepresentation));

        Response response = keycloak.realm("master").users().create(userRepresentation);
        System.out.println("response status: " + response.getStatus());

 

參考

https://www.keycloak.org/docs/latest/server_development/

END

你可能感興趣的文章

使用poi 解析 docx 原先是想解析出在docx 中的文字跟圖片, 但是, 有些我們認為是圖片, 其實是用方程式表示, 實在是太麻煩了 就記錄一

[vue.js] 設定 content type 今天在wickt 端怎麼就是收不到vue.js 以post 傳過來的資料 找了好久才發現 application/jso

讀取特定資料夾下的xls檔 讀取特定資料夾下的xls檔

java.time 時間 instant java.time

spring boot 使用jdbc連接mariadb spring boot, mariadb, jdbc, rowmapper

利用maven建立一個可執行的jar檔 利用maven建立一個可執行的jar檔

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[vue.js] 動態的props 做parent-child components 雙向綁定 vue.js props components camel-case

download a file from spring boot controllers ownload a file from spring boot controllers

proxmox lxc 救援 今天突然接到一名強者我朋友的臨時求援 他說他把pve 從5.1升到5.2後, kvm的虛擬机器都沒問題 , 但是lxc的

hoc2018灑水機器人 灑水機器人的工作是替行道樹灑水,機器人的灑水範圍有限(左前方、左方、左後方),請寫程式控制機器 人判斷須灑水的狀況。每顆

將google試算表當作簡易資料庫,利用Google apps cript 在網頁上操作查詢 將google試算表當作簡易資料庫,利用apps cript 在網頁上操作查詢 若我有一試算表資料 縣市 status