question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Failed to get user details from Visual Studio Code

See original GitHub issue

Describe the bug

I am trying to use DefaultAzureCredential from the azure-identity python package, but it will not work together with VS code.

I have logged into Azure in VS Code using the “Azure Account” extension. The device code login does work for my setup, but not the VisualStudioCodeCredential.

A similiar report can be found here: Azure/azure-sdk-for-net#14770. However, I am on Windows.

Expected behavior

The credential should be retrieved from VS code.

Actual behavior (include Exception or Stack Trace)

I get the exception: CredentialUnavailableError: Failed to get Azure user details from Visual Studio Code.

To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. Use VisualStudioCodeCredential().
  2. Query the Graph API using the msgraphcore package.

Environment:

  • Name and version of the Library package used: azure-identity==1.5.0, msgraphcore==0.0.2
  • Hosting platform or OS and .NET runtime version (dotnet --info output for .NET Core projects): Windows 10 Pro, Python 3.8.3
  • IDE and version : Visual Studio Code 1.54.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chlowellcommented, Mar 16, 2021

Thanks for opening this issue. VisualStudioCodeCredential attempts to read VS Code’s settings and authentication data. One possible point of failure is that when it can’t read the settings, it assumes you’re signed in to Azure Public Cloud, and will fail to authenticate if you are not. So, first question–are you logged in to a different cloud?

If not, could you please try it again with debug-level logging? For example:

import logging
import sys

logger = logging.getLogger('azure.identity')
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(stream=sys.stdout)
logger.addHandler(handler)

That will capture the details of any exception.

1reaction
jsquirecommented, Mar 16, 2021

Hi @kummerer94. Thank you for reaching out and we regret that you’re experiencing difficulties. I’m going to move this over to the Python SDK repository to ensure that the folks best able to assist can be looped in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Terminal launch failures - Visual Studio Code
Below are specific troubleshooting steps, if the user guide hasn't helped you diagnose the launch failure. The troubleshooting steps, such as checking your ......
Read more >
[BUG] VSCode Credential doesn't work #15428 - GitHub
Describe the bug When I use DefaultAzureCredential locally with myself logged in only via the VS Code Extension, I run into an exception....
Read more >
How to fix Git error in VS code - YouTube
How to fix Git error in VS code - ' Make sure you configure your ' user. name ' and ' user.email' in...
Read more >
How can I fix "build failed, do you want to continue"? In Visual ...
I resolved this issue by clearing the workspace cache in Visual Studio Code. Here is a link to the relevant page: Visual Studio...
Read more >
Fix program errors and improve code - Visual Studio (Windows)
This article describes some basic ways Visual Studio can help you find and fix problems in your code, including build errors, code analysis, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found