;; this worked for me ;; (defn access-token [] (-> (client/post (str base-url "/auth/realms/" realm "/protocol/openid-connect/token") {:accept :json :form-params {"client_id" "admin-cli" "username" some-username "password" default-password "grant_type" "password"}}) :body (json/read-str :key-fn keyword) :access_token)) (defn list-users [] (-> (client/get (str base-url "/auth/admin/realms/" realm "/users") {:headers {"Authorization" (clojure.string/join " " ["bearer" (access-token)])}}) :body (json/read-str :key-fn keyword))) (defn create-user [{:keys [email id name]}] (-> (client/post (str base-url "/auth/admin/realms/" realm "/users") {:headers {"Authorization" (clojure.string/join " " ["bearer" (access-token)])} :content-type "application/json" :body (json/write-str {:email email :username id})}))) (defn update-user [{:keys [id] :as m}] (client/put (str base-url "/auth/admin/realms/" realm "/users/" id) {:headers {"Authorization" (clojure.string/join " " ["bearer" (access-token)])} :content-type "application/json" :body (json/write-str m)})) (defn user-enable [m] (update-user (assoc m :enabled true))) (defn reset-password [{:keys [id password]}] (-> (client/put (str base-url "/auth/admin/realms/" realm "/users/" id "/reset-password") {:headers {"Authorization" (clojure.string/join " " ["bearer" (access-token)])} :content-type "application/json" :body (json/write-str {"type" "password" "value" password "temporary" false})})))