git - How to use the new CredentialsProvider in LibGit2Sharp? -
i using libgit2sharp.credentials class time @ following way:
libgit2sharp.credentials credentials = new usernamepasswordcredentials() { username = tokenvalue, password = "" }; var pushoptions = new pushoptions() { credentials = credentials} ;
now libgit2sharp.pushoptions.credentials obsolate, have use credentialsprovider.
i want ask correct way use credentialsprovider
in case?
thank much!
>i want ask correct way work credentialsprovider @ case?
this piece of code should fit need.
var pushoptions = new pushoptions() { credentialsprovider = (_url, _user, _cred) => new usernamepasswordcredentials { username = tokenvalue, password = "" } }
this has been introduced pr #761 in order allow more interactive scenarios (when user being asked credentials part of clone process, instance) , prepare path other kinds of credentials (ssh, instance).
the credentialsprovider
callback which
- passes in url being targeted, username (if specified in url) , type of credentials server accepts
- expects in return
credentials
(base type) used during authentication
one can see example of credentialsproviders
in action in clonefixture.cs test suite.
Comments
Post a Comment