libgit2 / libgit2/libgit2sharp
Fetch and Pull using Personal Access token
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 3.5k
- Forks
- 925
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par CredentialsHandler et UsernamePasswordCredentials, transmis à Commands.Fetch et Commands.Pull. Reproduisez fetch et pull avec les variantes d’identifiants fournies, consignez l’erreur exacte et déterminez le comportement d’authentification pris en charge pour les personal access tokens ; le travail est terminé lorsque les deux opérations s’authentifient correctement.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp, git
- Domaine
- authentication, tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100