libgit2 / libgit2/libgit2sharp
How can we commit changes using the access token key that gets generated using oauth support in gitHub
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CloneOptions and PushOptions credential setup in the issue, using LibGit2Sharp 0.26.2 on .NET 5.0. Reproduce the 403 during the Network.Push call and inspect the remote, refspec, and credentials involved. Done means the staged change can be committed and pushed to the GitHub repository with the OAuth token.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, git, github
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100