diff --git a/src/graph/auth.ts b/src/graph/auth.ts index 7ba86f3..e16c5ae 100644 --- a/src/graph/auth.ts +++ b/src/graph/auth.ts @@ -32,14 +32,15 @@ export function getMsalAuthProvider( }; } -export function getAzureIdentityAuthProvider( - tenantId: string, - clientId: string, -) { - const credential = new DefaultAzureCredential({ - tenantId, - managedIdentityClientId: clientId, - }); +export function getAzureIdentityAuthProvider(tenantId?: string, clientId?: string) : GraphAuthProvider { + const credentialOptions = + tenantId && clientId + ? { tenantId, managedIdentityClientId: clientId } + : undefined; + + const credential = credentialOptions + ? new DefaultAzureCredential(credentialOptions) + : new DefaultAzureCredential(); const getBearerToken = getBearerTokenProvider( credential,