Xaero Degreaz
Xaero Degreaz

Reputation: 1085

How can one supply credentials during a Fetch call?

We're not talking about SSH since it's not yet implemented, but how can I supply credentials for the repository before I perform a fetch via HTTP/HTTPS? There doesn't seem to be a parameter for a Credentials instance, and nothing when constructing a Repository instance for storing credentials.

Upvotes: 1

Views: 809

Answers (1)

nulltoken
nulltoken

Reputation: 67639

Within the FetchFixture.cs file, there is a Fetch() test using credentials:

    [SkippableFact]
    public void CanFetchIntoAnEmptyRepositoryWithCredentials()
    {
        InconclusiveIf(() => string.IsNullOrEmpty(Constants.PrivateRepoUrl),
            "Populate Constants.PrivateRepo* to run this test");

        string repoPath = InitNewRepository();

        using (var repo = new Repository(repoPath))
        {
            Remote remote = repo.Network.Remotes.Add(remoteName, Constants.PrivateRepoUrl);

            // Perform the actual fetch
            repo.Network.Fetch(remote, new FetchOptions
            {
                Credentials = new Credentials
                    {
                        Username = Constants.PrivateRepoUsername,
                        Password = Constants.PrivateRepoPassword
                    }
            });
        }
    }

Upvotes: 4

Related Questions