keycloak-scim/apps/admin-ui/src/context/auth/admin-ui-endpoint.ts
Erik Jan de Wit 93b0144ff3
added group endpoint that also returns access (#3170)
* added group endpoint that also returns access

fixes: #3163

* convert to java

* fixed merge errors
2022-08-31 20:06:29 -04:00

24 lines
710 B
TypeScript

import KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { getAuthorizationHeaders } from "../../utils/getAuthorizationHeaders";
import { joinPath } from "../../utils/joinPath";
export async function fetchAdminUI(
adminClient: KeycloakAdminClient,
endpoint: string,
query?: Record<string, string>
) {
const accessToken = await adminClient.getAccessToken();
const baseUrl = adminClient.baseUrl;
const response = await fetch(
joinPath(baseUrl, "admin/realms", adminClient.realmName, endpoint) +
(query ? "?" + new URLSearchParams(query) : ""),
{
method: "GET",
headers: getAuthorizationHeaders(accessToken),
}
);
return await response.json();
}