Skip to content

Commit

Permalink
Restore logic for default scope if not provided in getAccessToken fun…
Browse files Browse the repository at this point in the history
…ction (#16)
  • Loading branch information
liguori authored Feb 13, 2024
1 parent 11f7c5b commit 70c4ad4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -193,4 +191,4 @@ export async function activate(context: vscode.ExtensionContext) {
export function deactivate() {
outputChannel.dispose();
ipc.server.stop();
}
}

0 comments on commit 70c4ad4

Please sign in to comment.