Skip to content

Commit 4c7608a

Browse files
CopilotAlive-Fish
andauthored
fix: use ClientSecretCredential instead of DefaultAzureCredential in graph-connector template (#15416)
* Initial plan * fix: not use DefaultAzureCredential but use ClientSecretCredential Co-authored-by: Alive-Fish <15262146+Alive-Fish@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Alive-Fish <15262146+Alive-Fish@users.noreply.github.com>
1 parent d5c2f24 commit 4c7608a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

templates/vsc/ts/graph-connector/src/graphClient.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DefaultAzureCredential } from "@azure/identity";
1+
import { ClientSecretCredential } from "@azure/identity";
22
import { Client, MiddlewareFactory } from "@microsoft/microsoft-graph-client";
33
import { TokenCredentialAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials/index.js";
44
import { LongRunningOperationMiddleware } from "./longRunningOperationMiddleware";
@@ -10,9 +10,11 @@ const delayInterval = 60_000; // 60 seconds
1010
* @returns A new instance of the Microsoft Graph client.
1111
*/
1212
export function getClient(): Client {
13-
const credential = new DefaultAzureCredential({
14-
requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"],
15-
});
13+
const credential = new ClientSecretCredential(
14+
process.env.AZURE_TENANT_ID!,
15+
process.env.AZURE_CLIENT_ID!,
16+
process.env.AZURE_CLIENT_SECRET!
17+
);
1618

1719
const authProvider = new TokenCredentialAuthenticationProvider(credential, {
1820
scopes: ["https://graph.microsoft.com/.default"],

0 commit comments

Comments
 (0)