libgit2 / libgit2/libgit2sharp

Fetch and Pull using Personal Access token

Đang mở
#1,818 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C#
Star
3.5k
Fork
925
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I'm trying to fetch and pull everytime a request come to the application. So basically im using my own username and password for the same as of now. But when i try to implement it with my personal access token, it throws error.

    var path = "my local drive path";
    using (var repo = new Repository(path))
    {
        FetchOptions options = new FetchOptions();
        options.CredentialsProvider = new CredentialsHandler((url, usernameFromUrl, types) =>
            new UsernamePasswordCredentials()
            {
                Username="xxxxx@yyy.com",
                Password = githubtoken //my personal token
            });

        foreach (Remote remote in repo.Network.Remotes)
        {
            IEnumerable<string> refSpecs = remote.FetchRefSpecs.Select(x => x.Specification);
            Commands.Fetch(repo, remote.Name, refSpecs, options, logMessage);
        }
    }
    //Console.WriteLine(logMessage);

    using (var repo = new Repository(path))
    {
        // Credential information to fetch
        LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions();
        options.FetchOptions = new FetchOptions();
        options.FetchOptions.CredentialsProvider = new CredentialsHandler(
            (url, usernameFromUrl, types) =>
                new UsernamePasswordCredentials()
                {
                    Username = "xxxx@yyy.com",
                    Password = githubtoken //my personal token
                });

        // User information to create a merge commit
        var signature = new LibGit2Sharp.Signature(
            new Identity("xxxx", "xxxx@yyy.com"), DateTimeOffset.Now);

        // Pull
        Commands.Pull(repo, signature, options);
    }

I tried replacing the token in place of the username and giving empty string in place of password. Still i'm getting the same error.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với CredentialsHandler và UsernamePasswordCredentials được truyền vào Commands.Fetch và Commands.Pull. Tái hiện fetch và pull bằng các biến thể thông tin xác thực được cung cấp, ghi lại chính xác lỗi và xác định hành vi xác thực personal-access-token được hỗ trợ; hoàn thành khi cả hai thao tác đều xác thực thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, git
Lĩnh vực
authentication, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.