Fetch and Pull using Personal Access token

オープン
#1,818 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp, git

調査の方向性

Commands.Fetch と Commands.Pull に渡される CredentialsHandler と UsernamePasswordCredentials から始めます。提供された認証情報のバリエーションを使って fetch と pull を再現し、正確なエラーを記録して、サポートされている personal-access-token 認証の動作を特定します。両方の操作で認証に成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C#
スター
3.5k
フォーク
925
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

libgit2/libgit2sharp のほかの issue

libgit2/libgit2sharp の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。