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

LibGit2SharpException: could not find appropriate mechanism for credentials #2087

Open
MichielOda opened this issue Mar 27, 2024 · 5 comments

Comments

@MichielOda
Copy link

Reproduction steps

Upgraded from v0.26.2 to v0.30.0, had compilation issues. Fair enough, we were quite out of date.
We changed the credentials provider as this was now located in the FetchOptions (see #2065).
I even tried setting the ProxyOptions.ProxyType to None as that was now Auto by default.

Has there anything changed regarding credentials between those versions? I didn't immediately spotted something on the releases/changes page.

Expected behavior

Everything keeps working as normal.

Actual behavior

Exception is thrown when trying to clone a repository:
LibGit2Sharp.LibGit2SharpException: could not find appropriate mechanism for credentials at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 136 at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) in /_/LibGit2Sharp/Core/Proxy.cs:line 278 at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in /_/LibGit2Sharp/Repository.cs:line 810

Version of LibGit2Sharp (release number or SHA1)

v0.30.0

Operating system(s) tested; .NET runtime tested

Windows 11
.NET Framework 4.8

@ethomson
Copy link
Member

You mentioned #2065 but I think that only applies to proxies? I'm not sure if something else changed. Can you show the set up for your credentials and / or auth callback, and the callback that you're using (if you're using one)?

What kind of provider are you authenticating to? Do you know what mechanism you are expecting to use? (Basic, NTLM, etc)

@MichielOda
Copy link
Author

In the meantime I tried every version between 0.26.2 & 0.30.0 and it starts to break when I update to 0.29.0. I mention #2065 as that caused breaking changes compilation-wise. But it seemed a very small change to fix it (move CredentialsProvider & OnTransferProgress (2 properties of CloneOptions we used) to the FetchOptions from the CloneOptions).

We use the DefaultCredentials() for the handler:
libGitCredHandler = (_url, _user, _cred) => new DefaultCredentials();

And the OnTransferProgress is basically eventing if I understood correctly and is used to show the progress in the UI.

I did the same changes in v0.28.0 as well (moving those to FetchOptions) and everything still works.

@michaelmsonne
Copy link

michaelmsonne commented Mar 30, 2024

I have some small issues with upgradeing my tool here https://github.com/michaelmsonne/GitHubBackupTool to use the new v. as stuff break and is changed - like 'CloneOptions' does not contain a definition for 'RepositoryOperationCompleted' and so on. Have tryed to move to the FetchOptions but not all works..

So for now the tool use v. 0.28

@davidsr2r
Copy link

davidsr2r commented Apr 15, 2024

Tracking this issue also, I can't set credentials to clone a repo at the moment so I'm going to go to v 0.28
Found the resolution in the mentioned issue below, we can resolve using:

var cloneOptions = new CloneOptions();
cloneOptions.FetchOptions.CredentialsProvider = ...

@MichielOda
Copy link
Author

Any update/idea on why the credentials don't work anymore from 0.29 onwards? We're stuck on 0.28 but as that version has been made deprecated, our security team wants us to update this NuGet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants