diff --git a/package-lock.json b/package-lock.json index 08da35cce..0de3a06ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@azure/ms-rest-azure-env": "^2.0.0", "@azure/storage-blob": "^12.24.0", "@microsoft/microsoft-graph-client": "^3.0.7", - "@microsoft/vscode-azext-utils": "^2.5.1", + "@microsoft/vscode-azext-utils": "^2.5.4", "@octokit/rest": "^21.0.1", "@vscode/extension-telemetry": "^0.9.7", "decompress": "^4.2.1", @@ -942,12 +942,13 @@ } }, "node_modules/@microsoft/vscode-azext-utils": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-2.5.1.tgz", - "integrity": "sha512-K9S25xSZ5jEy5ofsLGdgzdXkyqzYhdJuBNkSRMa/7Qt6S+YtspQ4qwX6gNGvlMHE3gPAXDHqxvn+yPmm4s5uYg==", + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-2.5.4.tgz", + "integrity": "sha512-EdpKtDvgxV5q2L+I169VDc4RxPf4jzJYVGU9SXBl2qcXb0GJRGtU5PUWkIvvQSvoH1Hh0ztw/wyIbgKi/2Ozgg==", + "license": "MIT", "dependencies": { - "@microsoft/vscode-azureresources-api": "^2.0.4", - "@vscode/extension-telemetry": "^0.9.0", + "@microsoft/vscode-azureresources-api": "^2.3.1", + "@vscode/extension-telemetry": "^0.9.6", "dayjs": "^1.11.2", "escape-string-regexp": "^2.0.0", "html-to-text": "^8.2.0", @@ -980,9 +981,10 @@ } }, "node_modules/@microsoft/vscode-azureresources-api": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azureresources-api/-/vscode-azureresources-api-2.1.0.tgz", - "integrity": "sha512-dqjLyHl0OJgnjEtMtZEDvA9YovszWnE2k3ktEcHiTHWZ62luYrhOQhMzJjGArSFH3ANRCWgS6A1q4OTjZoBrKQ==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azureresources-api/-/vscode-azureresources-api-2.3.1.tgz", + "integrity": "sha512-ScuGp3/Znfpumg0UGGc9uWTJ86rEuHgFk5g/YCpkAwBBCM+yAHgY24sQ41oQXq9ycKPnL73MUoKCH/TX5vQnDA==", + "license": "MIT", "peerDependencies": { "@azure/ms-rest-azure-env": "^2.0.0" } diff --git a/package.json b/package.json index 0abc0c5dc..1e5559135 100644 --- a/package.json +++ b/package.json @@ -560,7 +560,7 @@ "@azure/ms-rest-azure-env": "^2.0.0", "@azure/storage-blob": "^12.24.0", "@microsoft/microsoft-graph-client": "^3.0.7", - "@microsoft/vscode-azext-utils": "^2.5.1", + "@microsoft/vscode-azext-utils": "^2.5.4", "@octokit/rest": "^21.0.1", "@vscode/extension-telemetry": "^0.9.7", "decompress": "^4.2.1", diff --git a/src/tree/azureAccountTreeItem.ts b/src/tree/azureAccountTreeItem.ts index 218d26c55..fd5b0ac96 100644 --- a/src/tree/azureAccountTreeItem.ts +++ b/src/tree/azureAccountTreeItem.ts @@ -16,6 +16,7 @@ import { getCredential, getEnvironment } from "../auth/azureAuth"; import { SelectionType, getSubscriptions } from "../commands/utils/subscriptions"; import { Subscription } from "@azure/arm-resources-subscriptions"; import { AzureSessionProvider, ReadyAzureSessionProvider, isReady } from "../auth/types"; +import { TokenCredential } from "@azure/identity"; export function createAzureAccountTreeItem( sessionProvider: AzureSessionProvider, @@ -200,5 +201,17 @@ function getSubscriptionContext( userId: session.account.id, environment, isCustomCloud: environment.name === "AzureCustomCloud", + createCredentialsForScopes: async (scopes: string[]): Promise => { + const authSession = await sessionProvider.getAuthSession({ scopes }); + if (failed(authSession)) { + throw new Error(`No Microsoft authentication session found: ${authSession.error}`); + } + + return { + getToken: async () => { + return { token: authSession.result.accessToken, expiresOnTimestamp: 0 }; + }, + }; + } }; }