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.

Could not obtain credentials’ error

See original GitHub issue

I created a NuGet package that enables source link by adding the following to the csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
        <PackageId>x</PackageId>
        <PackageVersion>0.0.12</PackageVersion>
        <Authors>y</Authors>
        <Owners>z</Owners>
        <Company>z</Company>
        <RepositoryUrl>repoUrl</RepositoryUrl>
        <RepositoryType>git</RepositoryType>
        <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
        <Description>a</Description>
        <PackageReleaseNotes>b</PackageReleaseNotes>
        <Copyright>Copyright</Copyright>
        <PackageTags>d</PackageTags>
    </PropertyGroup>
    <PropertyGroup>
        <PublishRepositoryUrl>true</PublishRepositoryUrl>
        <IncludeSymbols>true</IncludeSymbols>
        <SymbolPackageFormat>snupkg</SymbolPackageFormat>
        <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
        <DebugType>portable</DebugType>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.SourceLink.AzureDevOpsServer.Git" Version="1.0.0" PrivateAssets="All"/>
        <SourceLinkAzureDevOpsServerGitHost Include="c" VirtualDirectory="tfs"/>
    </ItemGroup>
</Project>

The build completes without error or warning with accurate sourcelink metadata in the obj folder. The NuGet package deploys to our internal packaging repository successfully. NuGet Package Explorer detects no errors and reports the proper Repository information.

Visual studio successfully finds the symbols when debugging and attempts to download the source via SourceLink.

The source download fails with the following error:

Looking for source using SourceLink(https://c/repoUrl)
Source Link errors:
git-credential-manager-core.exe: Could not obtain credentials. Unexpected output: ‘protocol=https
host=c
username=
password=

‘.
ERROR: The request failed with code 401 : “Unauthorized”.
The file was not found with SourceLink

I have Visual Studio 2019 16.11.1 configured to use git-credential-manager-core (installed by Visual Studio Installer => Git For Windows) and I am able to successfully push to the Remote repo using the Git Changes window.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\etc\gitconfig

[credential]
    helper = manager-core
[include]
    ; include Git for Windows' system config in order
    ; to inherit settings like `core.autocrlf`
    path = C:/Program Files (x86)/Git/etc/gitconfig
    path = C:/Program Files/Git/etc/gitconfig

I have to imagine the version of git-credential-manager-core used by SourceLink is looking for a different gitconfig? I have to assume it’s missing the credentials? On the same window as the error above there is a blue link to “Authenticate with SourceLink(repoUrl)” and clicking it doesn’t seem to do anything.

C:\WINDOWS\System32>git --version
git version 2.31.1.windows.1

C:\WINDOWS\System32>git credential-manager-core --version
2.0.394-beta+3fc6791abf

I tried to use git credential-manager-core store to store a PAT for AzureDevOpsServer but I am unable to make it through the prompt without it erroring about “fatal: parsing “*.domain.com” - Quantifier {x,y} following nothing.”. I wasn’t able to figure out what its looking for. I tried typing these one line at a time and pressing enter. then a double enter at the end.

protocol=https
host=domain.com
username=test
password=pattoken

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bwilliams1commented, Aug 26, 2021

@chuckries @tmat the /sources path was user error 😦 I forgot to update both NuGet packages in my test solution when trying to test after making some dockerfile changes.

image

1reaction
chuckriescommented, Aug 26, 2021

@bwilliams1 I also just noticed that you’re using Azure DevOps but this is falling into GCM based authentication, which is not expected. Are you using hosted Azure DevOps (i.e. a .visualstudio.com or dev.azure.com account)? Or are you using Azure DevOps Server which is hosted on prem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solving the error “Could not retrieve credential from local ...
To overcome this issue and clear the credentials, you can use a simple command: az account clear . Running the az account clear...
Read more >
the credentials within your profile may have expired - MacOS
After downloading the profile and try install it, the follow error shows "Could not obtain the final profile using the Encrypted Profile Service....
Read more >
BadCredentialsException: Could not obtain access token - ...
I updated my client configuration to use Github instead of my own Spring OAuth2 authorization server and it works. To me that indicates...
Read more >
401 Unauthorized Error: What It Is and How to Fix It
The 401 Unauthorized Error is an HTTP response status code indicating that the client could not authenticate a request.
Read more >
Re: OneDrive Plugin : Could not obtain OAuth2 credential
The answer is in the error message, the Client Secret Value from Azure App Registration needs to be used in DSS OneDrive Credentials...
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