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";
|
||||
|
||||
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";
|
||||
|
||||
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");
|
||||
const authProvider =
|
||||
config.authMode === "azure-identity"
|
||||
? getAzureIdentityAuthProvider(authConfig.tenantId, authConfig.clientId)
|
||||
: getMsalAuthProvider(authConfig.tenantId, authConfig.clientId);
|
||||
authProvider = getMsalAuthProvider(authConfig.tenantId, authConfig.clientId);
|
||||
}
|
||||
|
||||
return Client.init({
|
||||
authProvider: authProvider,
|
||||
|
||||
Reference in New Issue
Block a user