I using the LibGit2Sharp.Credentials class for some time at the following way:
LibGit2Sharp.Credentials credentials = new UsernamePasswordCredentials()
{
Username = TokenValue,
Password = ""
};
var pushOptions = new PushOptions() { Credentials = credentials} ;
Now the LibGit2Sharp.PushOptions.Credentials is obsolate, I have to use CredentialsProvider.
I want to ask you what is the correct way to use CredentialsProvider
in this case?
Thank you very much!
>I want to ask you what is the correct way to work with CredentialsProvider at this case?
This piece of code should fit your need.
var pushOptions = new PushOptions() {
CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
{
Username = TokenValue,
Password = ""
}
}
This has been introduced by PR #761 in order to allow some more interactive scenarios (when the user is being asked for his credentials as part of the clone process, for instance) and prepare the path for other kinds of credentials (Ssh, for instance).
The CredentialsProvider
is a callback which
Credentials
(base type) which will be used during the authenticationOne can see an example of the CredentialsProviders
in action in the CloneFixture.cs test suite.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With