libgit2Sharp PushOptions Credentialshandler 错误
libgit2Sharp PushOptions Credentialshandler error
我在凭据处理程序上使用 libgit2Sharp github wiki 中的示例时遇到错误。 (https://github.com/libgit2/libgit2sharp/wiki/git-push <- 第一个)
PushOptions opt = new PushOptions();
options.CredentialsProvider = new CredentialsHandler(("url here",
"username", (I don't know the type right now)) => new
UsernameAndPasswordCredentials(){...});
我遇到了几个错误放置的标记错误,例如在两个字符串之后的 ',' 上。谁能帮帮我或者给我一个推送的例子?
示例中您需要替换的唯一部分代码是大写的 USERNAME
和 PASSWORD
。 FetchOptions
中的 Credentials
字段是一个回调,如果服务器要求用户凭据,libgit2sharp 将调用该回调。示例代码使用带 lambda syntax 的内联委托来缩短示例,但您可以根据需要将回调函数定义为其他地方的方法或函数。
请注意,此特定示例假设您提前知道服务器将要求什么样的身份验证,并且您也知道正确的用户名和密码是什么。
我在凭据处理程序上使用 libgit2Sharp github wiki 中的示例时遇到错误。 (https://github.com/libgit2/libgit2sharp/wiki/git-push <- 第一个)
PushOptions opt = new PushOptions();
options.CredentialsProvider = new CredentialsHandler(("url here",
"username", (I don't know the type right now)) => new
UsernameAndPasswordCredentials(){...});
我遇到了几个错误放置的标记错误,例如在两个字符串之后的 ',' 上。谁能帮帮我或者给我一个推送的例子?
示例中您需要替换的唯一部分代码是大写的 USERNAME
和 PASSWORD
。 FetchOptions
中的 Credentials
字段是一个回调,如果服务器要求用户凭据,libgit2sharp 将调用该回调。示例代码使用带 lambda syntax 的内联委托来缩短示例,但您可以根据需要将回调函数定义为其他地方的方法或函数。
请注意,此特定示例假设您提前知道服务器将要求什么样的身份验证,并且您也知道正确的用户名和密码是什么。