forked from ccouzens/keycloak-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
33 lines (28 loc) · 890 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ClientsApi, Configuration } from "./keycloak-client";
import { Issuer } from "openid-client";
(async () => {
const keycloakIssuer = await Issuer.discover(
"http://localhost:8080/auth/realms/master/"
);
const openIdConnectClient = new keycloakIssuer.Client({
client_id: "admin-cli",
client_secret: "unused",
});
const token = await openIdConnectClient.grant({
grant_type: "password",
username: "admin-user",
password: "admin-password",
});
const config = new Configuration({
accessToken: token.access_token,
basePath: "http://localhost:8080/auth/admin/realms",
});
const clients = await new ClientsApi(config).realmClientsGet("master");
console.log("The default clients:");
for (const client of clients.data) {
console.log(` ${client.clientId}`);
}
})().catch((err) => {
console.error(err);
process.exit(1);
});