libgit2 / libgit2/libgit2sharp
How can we commit changes using the access token key that gets generated using oauth support in gitHub
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 3.5k
- Forks
- 925
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece com a configuração de credenciais de CloneOptions e PushOptions na issue, usando LibGit2Sharp 0.26.2 no .NET 5.0. Reproduza o 403 durante a chamada a Network.Push e inspecione o remote, o refspec e as credenciais envolvidas. Está concluído quando a alteração staged puder ser commitada e enviada para o repositório do GitHub com o token OAuth.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, git, github
- Domínio
- authentication
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100