Skip to content

Commit 83add75

Browse files
authored
Remove msal-node dependency (Azure#15481)
- Leverage @azure/identity MSAL wrapper
1 parent f25bd1f commit 83add75

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

sdk/communication/communication-identity/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
"tslib": "^2.0.0"
8686
},
8787
"devDependencies": {
88-
"@azure/msal-node": "^1.0.2",
8988
"@azure/dev-tool": "^1.0.0",
9089
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
9190
"@azure/test-utils": "^1.0.0",

sdk/communication/communication-identity/test/public/node/exchangeTeamsToken.node.spec.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { assert } from "chai";
55
import { matrix } from "@azure/test-utils";
66
import { env, isPlaybackMode, Recorder } from "@azure/test-utils-recorder";
7-
import * as msal from "@azure/msal-node";
7+
import { UsernamePasswordCredential } from "@azure/identity";
88
import { CommunicationAccessToken, CommunicationIdentityClient } from "../../../src";
99
import {
1010
createRecordedCommunicationIdentityClient,
@@ -47,26 +47,18 @@ matrix([[true, false]], async function(useAad) {
4747
it("successfully exchanges a Teams token for an ACS token", async function() {
4848
recorder.skip();
4949

50-
const msalConfig = {
51-
auth: {
52-
clientId: env.COMMUNICATION_M365_APP_ID,
53-
authority: `${env.COMMUNICATION_M365_AAD_AUTHORITY}/${env.COMMUNICATION_M365_AAD_TENANT}`
54-
}
55-
};
56-
57-
const request = {
58-
username: env.COMMUNICATION_MSAL_USERNAME,
59-
password: env.COMMUNICATION_MSAL_PASSWORD,
60-
scopes: [env.COMMUNICATION_M365_SCOPE]
61-
};
62-
63-
const pca = new msal.PublicClientApplication(msalConfig);
50+
const credential = new UsernamePasswordCredential(
51+
env.COMMUNICATION_M365_AAD_TENANT,
52+
env.COMMUNICATION_M365_APP_ID,
53+
env.COMMUNICATION_MSAL_USERNAME,
54+
env.COMMUNICATION_MSAL_PASSWORD
55+
);
6456

65-
const response = await pca.acquireTokenByUsernamePassword(request);
57+
const response = await credential.getToken([env.COMMUNICATION_M365_SCOPE]);
6658
assert.isNotNull(response);
6759

6860
const { token, expiresOn }: CommunicationAccessToken = await client.exchangeTeamsToken(
69-
response!.accessToken
61+
response!.token
7062
);
7163
assert.isString(token);
7264
assert.instanceOf(expiresOn, Date);

sdk/communication/communication-identity/test/public/utils/recordedClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const replaceableVariables: { [k: string]: string } = {
4242
COMMUNICATION_MSAL_USERNAME: "MSALUsername",
4343
COMMUNICATION_MSAL_PASSWORD: "MSALPassword",
4444
COMMUNICATION_M365_APP_ID: "M365AppId",
45-
COMMUNICATION_M365_AAD_AUTHORITY: "M365AADAuthority",
4645
COMMUNICATION_M365_AAD_TENANT: "M365AADTenant",
4746
COMMUNICATION_M365_SCOPE: "M365Scope",
4847
SKIP_INT_IDENTITY_EXCHANGE_TOKEN_TEST: "true"

0 commit comments

Comments
 (0)