25 lines
745 B
TypeScript
25 lines
745 B
TypeScript
// SPDX-License-Identifier: MIT
|
|
|
|
export * from "./auth.ts";
|
|
export * from "./app.ts";
|
|
export * from "./sp.ts";
|
|
|
|
import { loadAuthConfig, loadConfig } from "../index.ts";
|
|
import { Client } from "@microsoft/microsoft-graph-client";
|
|
|
|
import { getMsalAuthProvider, getAzureIdentityAuthProvider } from "./auth.ts";
|
|
|
|
export async function getGraphClient(): Promise<Client> {
|
|
const config = await loadConfig();
|
|
|
|
const authConfig = await loadAuthConfig("public-config");
|
|
const authProvider =
|
|
config.authMode === "azure-identity"
|
|
? getAzureIdentityAuthProvider(authConfig.tenantId, authConfig.clientId)
|
|
: getMsalAuthProvider(authConfig.tenantId, authConfig.clientId);
|
|
|
|
return Client.init({
|
|
authProvider: authProvider,
|
|
});
|
|
}
|