Skip to content

LibGit2Sharp.LibGit2SharpException:“too many redirects or authentication replays” #2119

Open
@Hdurian-CH

Description

@Hdurian-CH

I get LibGit2Sharp.LibGit2SharpException:“too many redirects or authentication replays” when I push the repository.
I use username&&password in CredentialsProvider

using var repo = new Repository(rootPath);
var options = new PushOptions
{
    CredentialsProvider = (url, user, cred) =>
        new UsernamePasswordCredentials { Username = userName, Password = password },
};

var remoteName = "origin";
var remote = repo.Network.Remotes.FirstOrDefault(r => r.Name == remoteName);
 if (remote == null)
{
     repo.Network.Remotes.Add(remoteName, res);
}

 var branch = repo.Branches["main"];
if (branch == null)
 {
     branch = repo.CreateBranch("main");
 }
repo.Branches.Update(branch, b => b.Remote = remoteName, b => b.UpstreamBranch = branch.CanonicalName);
repo.Network.Push(branch, options);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Hdurian-CH

        Issue actions

          LibGit2Sharp.LibGit2SharpException:“too many redirects or authentication replays” · Issue #2119 · libgit2/libgit2sharp