diff --git a/README.md b/README.md index c7388af..c9fa4c4 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - `get-access-token` - This command will print an access token to stdout. Other tools can integrate this for getting ADO credentials, for eg, authenticating to ADO Artifact Feeds (NPM, Nuget). - This extension is not recommended to be installed by itself. You should instead use the [external-repository](https://github.com/microsoft/codespace-features/tree/main/src/external-repository) and [artifacts-helper](https://github.com/microsoft/codespace-features/tree/main/src/artifacts-helper) devcontainer features which will ensure this extension is preinstalled on your Codespace with proper configuration. -### New in versione 1.2 +### New in version 1.2 - Add the `adoCodespacesAuth.tenantID` setting ### New in version 1.1 diff --git a/src/extension.ts b/src/extension.ts index 17e29ab..fa71965 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -53,8 +53,13 @@ const statusBarItem = vscode.window.createStatusBarItem( ); const getAccessToken = async ( - scopes: readonly string[] + scopes = [DEFAULT_ADO_SCOPE] ) => { + const tenantID = vscode.workspace.getConfiguration("adoCodespacesAuth").get('tenantID'); + if (tenantID && tenantID !== '') { + scopes.push(`VSCODE_TENANT:${tenantID}`); + } + let session = await vscode.authentication.getSession("microsoft", scopes, { silent: true, }); @@ -111,14 +116,7 @@ const createHelperExecutable = ( const authenticateAdo = async (context: vscode.ExtensionContext) => { try { - const scopes = [DEFAULT_ADO_SCOPE]; - - const tenantID = vscode.workspace.getConfiguration("adoCodespacesAuth").get('tenantID'); - if (tenantID && tenantID !== '') { - scopes.push(`VSCODE_TENANT:${tenantID}`); - } - - await getAccessToken(scopes); + await getAccessToken(); createHelperExecutable(context, "ado-auth-helper"); createHelperExecutable(context, "azure-auth-helper"); @@ -193,4 +191,4 @@ export async function activate(context: vscode.ExtensionContext) { export function deactivate() { outputChannel.dispose(); ipc.server.stop(); -} +} \ No newline at end of file