Refactor of authentication code. Added configuration file selectable authentication method. Selectable from built-in Azure Identity, and custom PCA using MSAL.
Some checks failed
build / build (push) Failing after 14s
Some checks failed
build / build (push) Failing after 14s
This commit is contained in:
@@ -3,3 +3,22 @@
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user