Skip to content

Commit 36fb9bb

Browse files
authored
Deprecated direct MAPI access. Fixed AAD button visibility logic. (#2845)
1 parent c98b19b commit 36fb9bb

File tree

84 files changed

+2277
-2584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2277
-2584
lines changed

auth/arm-auth.js

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
1-
const { InteractiveBrowserCredential } = require('@azure/identity');
2-
3-
/**
4-
* Gets authentication ARM token using interactive browser authentication
5-
* @param {Object} options - Configuration options
6-
* @param {string} [options.tenantId] - Optional tenant ID to override default tenant
7-
* @param {string} [options.clientId] - Optional client ID for the application
8-
* @returns {Promise<string>} - Bearer token for portal.azure.com
9-
*/
10-
async function getArmToken(options = {}) {
11-
try {
12-
const credential = new InteractiveBrowserCredential({
13-
tenantId: options.tenantId,
14-
clientId: options.clientId
15-
});
16-
console.log("Please sign in via the browser window that will open...");
17-
18-
// Get the token - this will open a browser window for authentication
19-
const scope = "https://management.azure.com/user_impersonation";
20-
const response = await credential.getToken(scope);
21-
22-
if (response && response.token) {
23-
console.log("Successfully acquired token with expiration at:", (new Date(response.expiresOnTimestamp)).toLocaleString());
24-
return `${response.tokenType} ${response.token}`;
25-
} else {
26-
throw new Error("Failed to acquire token: Empty response");
27-
}
28-
} catch (error) {
29-
console.error("Error acquiring portal token:", error.message);
30-
throw error;
31-
}
32-
}
33-
34-
module.exports = {
35-
getArmToken
36-
};
1+
const { InteractiveBrowserCredential } = require('@azure/identity');
2+
3+
/**
4+
* Gets authentication ARM token using interactive browser authentication
5+
* @param {Object} options - Configuration options
6+
* @param {string} [options.tenantId] - Optional tenant ID to override default tenant
7+
* @param {string} [options.clientId] - Optional client ID for the application
8+
* @returns {Promise<string>} - Bearer token for portal.azure.com
9+
*/
10+
async function getArmToken(options = {}) {
11+
try {
12+
const credential = new InteractiveBrowserCredential({
13+
tenantId: options.tenantId,
14+
clientId: options.clientId,
15+
loginStyle: "popup"
16+
});
17+
18+
console.log("Please sign in via the browser window that will open...");
19+
20+
// Get the token - this will open a browser window for authentication
21+
const scope = "https://management.azure.com/user_impersonation";
22+
const response = await credential.getToken(scope);
23+
24+
if (response && response.token) {
25+
console.log("Successfully acquired token with expiration at:", (new Date(response.expiresOnTimestamp)).toLocaleString());
26+
27+
return `${response.tokenType} ${response.token}`;
28+
}
29+
else {
30+
throw new Error("Failed to acquire token: Empty response");
31+
}
32+
}
33+
catch (error) {
34+
console.error("Error acquiring portal token:", error.message);
35+
throw error;
36+
}
37+
}
38+
39+
module.exports = {
40+
getArmToken
41+
};

0 commit comments

Comments
 (0)