Fix: Do not require PCA to be configured for Azure Identity default authentication.
This commit is contained in:
@@ -5,18 +5,21 @@ export * from "./app.ts";
|
|||||||
export * from "./sp.ts";
|
export * from "./sp.ts";
|
||||||
|
|
||||||
import { loadAuthConfig, loadConfig } from "../index.ts";
|
import { loadAuthConfig, loadConfig } from "../index.ts";
|
||||||
import { Client } from "@microsoft/microsoft-graph-client";
|
import { Client, AuthProvider } from "@microsoft/microsoft-graph-client";
|
||||||
|
|
||||||
import { getMsalAuthProvider, getAzureIdentityAuthProvider } from "./auth.ts";
|
import { getMsalAuthProvider, getAzureIdentityAuthProvider } from "./auth.ts";
|
||||||
|
|
||||||
export async function getGraphClient(): Promise<Client> {
|
export async function getGraphClient(): Promise<Client> {
|
||||||
const config = await loadConfig();
|
const config = await loadConfig();
|
||||||
|
|
||||||
const authConfig = await loadAuthConfig("public-config");
|
let authProvider: AuthProvider;
|
||||||
const authProvider =
|
|
||||||
config.authMode === "azure-identity"
|
if (config.authMode === "azure-identity") {
|
||||||
? getAzureIdentityAuthProvider(authConfig.tenantId, authConfig.clientId)
|
authProvider = getAzureIdentityAuthProvider();
|
||||||
: getMsalAuthProvider(authConfig.tenantId, authConfig.clientId);
|
} else {
|
||||||
|
const authConfig = await loadAuthConfig("public-config");
|
||||||
|
authProvider = getMsalAuthProvider(authConfig.tenantId, authConfig.clientId);
|
||||||
|
}
|
||||||
|
|
||||||
return Client.init({
|
return Client.init({
|
||||||
authProvider: authProvider,
|
authProvider: authProvider,
|
||||||
|
|||||||
Reference in New Issue
Block a user