【问题标题】:LibGit2Sharp - Fetch, Push, Pull - Too many redirects or authentication replaysLibGit2Sharp - 获取、推送、拉取 - 重定向或身份验证重放过多
【发布时间】:2015-12-11 02:54:12
【问题描述】:

DefaultCredential 的重定向或身份验证重播过多。当我使用 UsernamePasswordCredentials 然后它工作正常。我不想传递用户名和密码。

【问题讨论】:

  • 请向我们展示您当前的代码,链接到您正在使用的库,并提供错误消息日志。
  • 代码:CredentialsHandler _credentials = (_url, _user, _cred) => new DefaultCredentials();字符串 cloneURl ="xyz.visualstudio.com/DefaultCollection/_git/xyz"; Uri scd = new Uri(@"C:\\\Repository\\cloneDesignDepot" + Guid.NewGuid()); var cloneOptions = new CloneOptions {BranchName = "master",Checkout = true,CredentialsProvider =_credentials };string clonerepositoryPath = string.Empty;clonerepositoryPath = Repository.Clone(cloneURl, scd.LocalPath, cloneOptions);
  • 错误:太多的重定向或身份验证在 LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) 在 LibGit2Sharp.Core.Ensure.HandleError(Int32 结果) 在 LibGit2Sharp 重播堆栈跟踪.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) at GitLibrary.Program.Clone() in C:\Repository\Practice\GitLibrary\GitLibrary\Program.cs:line 50

标签: libgit2sharp


【解决方案1】:

服务器不接受凭据。服务器未设置为接受登录用户的 NTLM/Kerberos 凭据,或者当前用户没有从该存储库读取的权限。

除非您 100% 确定凭据是正确的并且它们永远不会出错,否则您不应该让您的凭据回调始终返回相同的信息而不检查这些凭据之前是否失败。如果您只返回相同的凭据并且不提供停止的方法,则库将继续循环。

在这种情况下,libgit2 WinHTTP 代码在重试请求时当前不会区分 URL 重定向和身份验证失败,因此它会停止并为您提供错误消息作为保护,以防服务器出现重定向循环;但总的来说,您不应该依赖这种情况。

【讨论】:

    猜你喜欢
    • 2014-11-26
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 2012-05-01
    • 1970-01-01
    • 2019-07-27
    • 1970-01-01
    • 2016-06-28
    相关资源
    最近更新 更多