git - 使用 LibGit2Sharp 的 Bitbucket 身份验证

标签 git mercurial bitbucket libgit2sharp bitbucket-api

我使用 CSharp.Bitbucket 库通过 Bitbucket ( https://github.com/scottksmith95/CSharp.Bitbucket ) 对用户进行身份验证。 身份验证工作正常,我得到了 token 值和 token secret 值。

我已经编写了一个逻辑 - 在 LibGit2Sharp ( https://github.com/libgit2/libgit2sharp ) 的帮助下 - 克隆/pull/推用户 repo 的内容。如果用户使用 GitHub 进行身份验证,它就可以正常工作。在这种情况下,我必须为用户名提供访问 token 的值,为密码提供一个空字符串。

 LibGit2Sharp.Credentials credentials = new UsernamePasswordCredentials()
        {
            Username = [GITHUB ACCESS TOKEN], 
            Password =""
        };

但是 Bitbucket 呢?我可以这样使用 LibGit2Sharp 吗?我找不到有关此问题的任何文档。我尝试将 token 值和 token 密码也用于用户名,但失败了。

enter image description here

我也想将 Bitbucket 与 Git 和 Mercurial 一起使用。有什么我至今没意识到的小技巧吗?

感谢您的帮助!

最佳答案

这种将 token 作为用户名和空白密码传递的方式特定于 GitHub AFAIK ( see this help article )。该文章还指出,传递 x-oauth-basic 是有效的。

BitBucket 问题 #7735 似乎声明将 token 作为用户名和 x-oauth-basic 传递也可以。

关于git - 使用 LibGit2Sharp 的 Bitbucket 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24607212/

相关文章:

mercurial - 如何使用 Mercurial 进行基于变更集的 merge ,而不是基于文件的 merge ?

git - 使用自定义私钥的 TeamCity Git VCS SSH 连接抛出 JschException : Auth fail

mercurial - 将多个子存储库 merge 为一个并在 Mercurial 中保留历史记录

git - 为什么 `git update-ref -d`不删除空的父目录?

git - 如何在存储库中的所有 Git 和 Mercurial 提交中搜索特定字符串?

git - 运行 jenkins 作业的 Bitbucket webhook

git - 使用 Git 的最佳方式是什么,是通过 HTTPS 还是通过 SSH?

git - 代码已从 bitbucket 存储库中消失

git - 版本控制 couchdb map-reduce 函数

git - YOCTO: "error: cannot run ssh: No such file or directory"