libgit2 / libgit2/libgit2sharp
Fetch and Pull using Personal Access token
オープン
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 3.5k
- フォーク
- 925
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Commands.Fetch と Commands.Pull に渡される CredentialsHandler と UsernamePasswordCredentials から始めます。提供された認証情報のバリエーションを使って fetch と pull を再現し、正確なエラーを記録して、サポートされている personal-access-token 認証の動作を特定します。両方の操作で認証に成功すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, git
- 領域
- authentication, tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100