libgit2 / libgit2/libgit2sharp
How can we commit changes using the access token key that gets generated using oauth support in 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ả
How can we commit changes to github using the access token generated using github Oauth.
I have got the access token and able to clone the repository using the code below
CloneOptions options = new CloneOptions();
var creds = new UsernamePasswordCredentials()
{
Username = "access token"
Password = string.Empty
};
CredentialsHandler credHandler = (_url, _user, _cred) => creds;
options.CredentialsProvider = credHandler;
string clonedRepoPath = Repository.Clone("repository", repoLocation, options);
repo = new Repository(repoLocation);
But unbale to commit the changes using the access token. below code fails with the error "'request failed with status code: 403"
Commands.Stage(repo, "abc.txt");
Signature sig = new Signature(new Identity("name", "email"), DateTimeOffset.Now);
Commit commit = repo.Commit("", sig, sig);
// Push to remote repository
var creds = new UsernamePasswordCredentials()
{
Username = "access token",
Password = ""
};
CredentialsHandler credHandler = (_url, _user, _cred) => creds;
var fetchOpts = new PushOptions { CredentialsProvider = credHandler };
repo.Network.Push(repo.Network.Remotes["origin"], "HEAD", @"refs/heads/master", fetchOpts);
Expected: Should be able to commit changes using access token.
Version of LibGit2Sharp (release number or SHA1)
LibGit2Sharp.0.26.2
Operating system(s) tested; .NET runtime tested
OSx, .net core 5.0
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với việc thiết lập thông tin xác thực cho CloneOptions và PushOptions trong issue, sử dụng LibGit2Sharp 0.26.2 trên .NET 5.0. Tái hiện lỗi 403 trong lệnh gọi Network.Push và kiểm tra remote, refspec và thông tin xác thực liên quan. Được xem là hoàn tất khi thay đổi đã staged có thể được commit và push lên GitHub repository bằng OAuth token.
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, github
- Lĩnh vực
- authentication
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100