gpt4 book ai didi

bitbucket - 为什么个人访问 token 不适用于 Bitbucket REST API?

转载 作者:行者123 更新时间:2023-12-05 04:47:06 29 4
gpt4 key购买 nike

TL/DR:(为什么)在 Bitbucket 网络用户界面中创建的名称/PAT 组合不适用于 Bitbucket REST API(或 repo 克隆)?

我一直在阅读 various documentation在 Bitbucket 上 REST APIPersonal Access Tokens ,目的是在调用前者时使用后者。

到目前为止,我所读到的所有内容都用更详尽的语言表明这是可能的。

接下来,我在 Bitbucket 网络用户界面中创建了一个个人访问 token (PAT)。根据下面的屏幕截图(贴在底部,以免打断文本流),PAT 名称为“test”,假设 PAT 值为Rzg4MGUyN4m4N9U3O1HQHO3ABJyp7xClvsan7sAmFEPy

为什么,当我尝试使用此 PAT 时,会出现“身份验证失败”错误?例如:

user@bld_svr:~$ curl -L -u test:Rzg4MGUyN4m4N9U3O1HQHO3ABJyp7xClvsan7sAmFEPy -H "Content-Type: application/json" -X POST https://bitbucket.svr.com/rest/build-status/1.0/commits/5764bb32f80813b3bbcbf6496c113c1830c52bb0 -d '{"state":"INPROGRESS","key":"job_434","url":"http://bld_svr:8080//blue/organizations/jenkins/prj/detail/prj/434/pipeline"}'
{"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}

我的阅读让我相信所有必要的是:

  1. 在 Bitbucket 用户界面中创建 PAT
  2. 使用名称/PAT 组合与使用用户名/密码相同

尝试稍微调试一下问题,this page ,具体来说,表示名称/PAT 应该可用于 git clone 存储库。但这也失败了:

$ git clone https://bitbucket.svr.com/scm/key/a_project.git
Cloning into 'a_project'...
Username for 'https://bitbucket.svr.com': test
Password for 'https://test@bitbucket.svr.com': # I typed in "Rzg4MGUyN4m4N9U3O1HQHO3ABJyp7xClvsan7sAmFEPy" here
fatal: Authentication failed for 'https://bitbucket.svr.com/scm/key/a_project.git/'

任何人都可以直接告诉我有关 Bitbucket PAT 的信息,以及它们应该如何配置/与 Bitbucket REST API 一起使用,甚至只是简单的 git clone正在?


enter image description here

最佳答案

the PAT Name is "test",

实际上,您需要使用您的 BitBucket 用户帐户名,而不是 PAT 名称,作为用户名:

git clone https://username:<token>@bitbucketserver.com/scm/projectname/teamsinspace.git

你也有语法 ( seen here )

git clone "https://x-token-auth:{tokenHere}@bitbucket.org/yourRepoOwnerHere/RepoNameHere"

你可以使用 gildas/git-credential-bitbucket作为缓存 token 并自动重用它的一种方式

git credential-bitbucket store <<EOM
protocol=https
host=bitbucket.org
username=xxx
clientid=yyy
secret=zzz

git remote add bitbucket https://xxx@bitbucket.org/path/to/repo.git
git config credential.helper bitbucket

关于bitbucket - 为什么个人访问 token 不适用于 Bitbucket REST API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68597002/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com