libgit2 / libgit2/libgit2sharp

How can we commit changes using the access token key that gets generated using oauth support in gitHub

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

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

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

説明

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

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

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

はじめの一歩

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

調査の方向性

issue 内の CloneOptions と PushOptions の認証情報設定から始め、.NET 5.0 上で LibGit2Sharp 0.26.2 を使用します。Network.Push の呼び出し中に 403 を再現し、関係する remote、refspec、認証情報を調査します。OAuth token を使用して、staged された変更を commit し、GitHub repository に push できれば完了です。

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

評価

技術スタック
csharp, git, github
領域
authentication
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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