Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode Credential doesn't work #11452

Closed
1 of 6 tasks
PIC123 opened this issue Sep 24, 2020 · 9 comments · Fixed by #11598
Closed
1 of 6 tasks

VSCode Credential doesn't work #11452

PIC123 opened this issue Sep 24, 2020 · 9 comments · Fixed by #11598
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team

Comments

@PIC123
Copy link

PIC123 commented Sep 24, 2020

  • Package Name: @azure/identity
  • Package Version: 1.1.0
  • Operating system: Windows 10
  • nodejs
    • version:
  • browser
    • name/version:
  • typescript
    • version: 4.0.2
  • Is the bug related to documentation in

Describe the bug
When trying to use the VisualStudioCodeCredential in the @azure/identity pakcage, you get an error:

azure:core-http:info ServiceClient: using custom request policies
azure:identity:info VisualStudioCodeCredential =>
[Error: Cannot autolaunch D-Bus without X11 $DISPLAY]

Installed keytar as some online posts mentioned, didn't change the output

To Reproduce
Steps to reproduce the behavior:

  1. Create a new VisualStudioCodeCredential
  2. try to use the credential for anything, i.e. getting a token

Expected behavior
The operation should succeed

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
I am an ms internal engineer, feel free to reach out for more context/clarifications

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 24, 2020
@ramya-rao-a ramya-rao-a added Azure.Identity Client This issue points to a problem in the data-plane of the library. labels Sep 24, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 24, 2020
@ramya-rao-a ramya-rao-a added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 24, 2020
@mhoeger
Copy link

mhoeger commented Sep 24, 2020

+1! Here is my exception:

[9/24/20 8:19:33 PM] Exception: AuthenticationError: invalid_scope(status code 400).
[9/24/20 8:19:33 PM] More details:
[9/24/20 8:19:33 PM] AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid. The scope https://management.core.windows.net/ offline_access is not valid. The scope format is invalid. Scope must be in a valid URI form <https://example/scope> or a valid Guid <guid/scope>.
[9/24/20 8:19:33 PM] Trace ID: 59a0d61e-7689-4448-b488-ce853c92dd00
[9/24/20 8:19:33 PM] Correlation ID: 437013bb-9829-44bb-8f73-43f7496c503c
[9/24/20 8:19:33 PM] Timestamp: 2020-09-24 20:19:33Z
[9/24/20 8:19:33 PM] Stack: AuthenticationError: invalid_scope(status code 400).
[9/24/20 8:19:33 PM] More details:
[9/24/20 8:19:33 PM] AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid. The scope https://management.core.windows.net/ offline_access is not valid. The scope format is invalid. Scope must be in a valid URI form <https://example/scope> or a valid Guid <guid/scope>.
[9/24/20 8:19:33 PM] Trace ID: 59a0d61e-7689-4448-b488-ce853c92dd00
[9/24/20 8:19:33 PM] Correlation ID: 437013bb-9829-44bb-8f73-43f7496c503c
[9/24/20 8:19:33 PM] Timestamp: 2020-09-24 20:19:33Z
[9/24/20 8:19:33 PM]     at IdentityClient.<anonymous> (/Users/mariehoeger/Documents/repos/Connectors/samples/azurefunctions/memeGenerator/node_modules/@azure/identity/dist/index.js:334:31)
[9/24/20 8:19:33 PM]     at Generator.next (<anonymous>)
[9/24/20 8:19:33 PM]     at fulfilled (/Users/mariehoeger/Documents/repos/Connectors/samples/azurefunctions/memeGenerator/node_modules/@azure/identity/node_modules/tslib/tslib.js:111:62)
[9/24/20 8:19:33 PM]     at process._tickCallback (internal/process/next_tick.js:68:7).

@sadasant
Copy link
Contributor

Hello @PIC123 and @mhoeger ! I'm Daniel,

I'll be doing my best to help you.

I'll have an answer for you shortly (as in, up to a couple of hours). Thank you for your patience!

@sadasant
Copy link
Contributor

@PIC123 , @mhoeger

I need some help!

For this credential, were you able to authenticate via the Azure Account Extension? https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account

I'll continue investigating tomorrow! thank you for your time.

@sadasant
Copy link
Contributor

sadasant commented Sep 25, 2020

I'm taking tomorrow off, but I'll come back to this on Monday for sure.

@PIC123
Copy link
Author

PIC123 commented Sep 25, 2020

Hey! So for me, if I use the VSCodeCredential, I just get the error I noted above, and it doesn't fall back to any login options. I have the extension set and logged in, but it seems to fail before reaching there even

@mhoeger
Copy link

mhoeger commented Sep 25, 2020

Hi @sadasant , thank you for the quick response, and enjoy the time off! I also have the extension installed and logged in.

On my end, one thing that I have a valid scope: //.default

My exception changed to this... I tried Azure Logout and then Azure Login again

[9/25/20 6:20:21 AM] System.Private.CoreLib: Exception while executing function: Functions.ShareMeme. System.Private.CoreLib: Result: Failure
[9/25/20 6:20:21 AM] Exception: AuthenticationError: invalid_grant(status code 400).
[9/25/20 6:20:21 AM] More details:
[9/25/20 6:20:21 AM] AADSTS700082: The refresh token has expired due to inactivity. The token was issued on (June) and was inactive for 90.00:00:00.
[9/25/20 6:20:21 AM] Trace ID: 91f46a8f-c408-4f3a-82a2-f12ca3c90e00
[9/25/20 6:20:21 AM] Correlation ID: a5dc4661-c70e-433c-8a65-bd494676d478
[9/25/20 6:20:21 AM] Timestamp: 2020-09-25 06:20:20Z
[9/25/20 6:20:21 AM] Stack: AuthenticationError: invalid_grant(status code 400).
[9/25/20 6:20:21 AM] More details:
[9/25/20 6:20:21 AM] AADSTS700082: The refresh token has expired due to inactivity. The token was issued on (June) and was inactive for 90.00:00:00.
[9/25/20 6:20:21 AM] Trace ID: 91f46a8f-c408-4f3a-82a2-f12ca3c90e00
[9/25/20 6:20:21 AM] Correlation ID: a5dc4661-c70e-433c-8a65-bd494676d478
[9/25/20 6:20:21 AM] Timestamp: 2020-09-25 06:20:20Z
[9/25/20 6:20:21 AM]     at IdentityClient.<anonymous> (/Users/mariehoeger/Documents/repos/Connectors/samples/azurefunctions/memeGenerator/node_modules/@azure/identity/dist/index.js:334:31)
[9/25/20 6:20:21 AM]     at Generator.next (<anonymous>)
[9/25/20 6:20:21 AM]     at fulfilled (/Users/mariehoeger/Documents/repos/Connectors/samples/azurefunctions/memeGenerator/node_modules/@azure/identity/node_modules/tslib/tslib.js:111:62)
[9/25/20 6:20:21 AM]     at process._tickCallback (internal/process/next_tick.js:68:7).

@sadasant sadasant added this to the [2020] October milestone Sep 28, 2020
@sadasant sadasant added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Sep 28, 2020
@sadasant
Copy link
Contributor

I was able to reproduce this issue. I'm working on it.

@sadasant
Copy link
Contributor

sadasant commented Oct 1, 2020

After some investigation and through a chat with the team, we've spotted the exact cause of the bug, and we've found a fix! I'll be making a detailed PR soon.

@sadasant
Copy link
Contributor

sadasant commented Oct 2, 2020

For the record, I was able to confirm the fix in #11598 was also valid for @mhoeger by working together through an internal chat.

@ghost ghost closed this as completed in #11598 Oct 2, 2020
ghost pushed a commit that referenced this issue Oct 2, 2020
…11598)

`VisualStudioCodeCredential` was not supporting multiple clouds, which can be configured. These changes automatically detect the  user defined cloud, and otherwise default to the first cloud found.

Fixes #11452 

To test this:

Using Visual Studio Code, and having the Azure Account extension installed, make a new folder, then place a package.json with the following content:

```json
{
  "name": "identity-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@azure/identity": "1.2.0-beta.1",
    "@azure/keyvault-keys": "^4.2.0-beta.1"
  }
}
```

Then an `index.js` file with:

```js
const identity = require("@azure/identity");
const { KeyClient } = require("@azure/keyvault-keys");

async function main() {
  const cred = new identity.VisualStudioCodeCredential();
  const keyVaultUrl = `https://<key-vault-name>.vault.azure.net`;
  const client = new KeyClient(keyVaultUrl, cred);

  console.log(await client.listPropertiesOfKeys().next());
}

main().then(console.log).catch((e) => console.error(e));
```

Run `npm install`, then build the identity client from this PR in a local copy of this project, then copy the `dist/index.js` file into `node_modules/@azure/identity/dist/index.js`.

This output makes the code above work. Without this change, it might not work by default, depending on what cloud VSCode has assigned in the settings.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants