Update: devops submodule convertion to new simpler auth model.

This commit is contained in:
2026-03-11 12:59:00 +01:00
parent 4dd3056b2f
commit d6adb5a3ba
3 changed files with 21 additions and 85 deletions

View File

@@ -1,27 +1,18 @@
// SPDX-License-Identifier: MIT
export * from "./auth.ts";
export * from "./app.ts";
export * from "./sp.ts";
import { loadAuthConfig, loadConfig } from "../index.ts";
import { Client, AuthProvider } from "@microsoft/microsoft-graph-client";
import { getMsalAuthProvider, getAzureIdentityAuthProvider } from "./auth.ts";
import { Client } from "@microsoft/microsoft-graph-client";
import { RESOURCE_SCOPE_BY_NAME, getTokenCredential } from "../azure/index.ts";
export async function getGraphClient(): Promise<Client> {
const config = await loadConfig();
let authProvider: AuthProvider;
if (config.authMode === "azure-identity") {
authProvider = getAzureIdentityAuthProvider();
} else {
const authConfig = await loadAuthConfig("public-config");
authProvider = getMsalAuthProvider(authConfig.tenantId, authConfig.clientId);
}
return Client.init({
authProvider: authProvider,
authProvider: (done) => {
void getTokenCredential()
.then((credential) => credential.getToken(RESOURCE_SCOPE_BY_NAME.graph))
.then((accessToken) => done(null, accessToken?.token ?? null))
.catch((err) => done(err as Error, null));
},
});
}