【问题标题】:LibGit2SharpException while fetching: 'too many redirects or authentication replays'获取时出现 LibGit2SharpException:“重定向或身份验证重放次数过多”
【发布时间】:2021-12-14 09:28:38
【问题描述】:

我在尝试使用 libgit2sharp 从我的存储库中获取数据时遇到问题。

我正在尝试从我的 Github 存储库中获取。它是通过 https 克隆的。一旦 fetch 命令运行,LibGit2SharpException 就会抛出:"too many redirects or authentication replays".

我已经在这里阅读了其他一些问题,但到目前为止,它们都没有帮助。使用DefaultCredentials 只会导致 401 错误,这是有道理的。

有人知道如何解决这个问题吗?

using Repository repo = new Repository(@"path\to\repo");

Remote remote = repo.Network.Remotes["origin"];

IEnumerable<string> refSpec = remote.FetchRefSpecs.Select(x => x.Specification);

Credentials credentials = new UsernamePasswordCredentials { Username = "USER", Password = "PASS" };

Credentials Handler(string url, string fromUrl, SupportedCredentialTypes types) => credentials;

FetchOptions options = new FetchOptions { CredentialsProvider = Handler };

string log = "Fetching remote";

Commands.Fetch(repo, remote.Name, refSpec, options, log);

编辑:据我所知,问题是,它是一个私人仓库,因为我可以从 github 获取公共仓库。关于如何解决它的任何想法?

【问题讨论】:

    标签: c# libgit2sharp


    【解决方案1】:

    我使用来自 Github 的 PersonalAccessToken 解决了这个问题。然后可以将 Token 用作凭证的密码

    【讨论】:

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