访问被拒绝。您必须具有写入或管理权限

2024-05-01 22:11:52 发布

您现在位置:Python中文网/ 问答频道 /正文

亲爱的stackoverflow社区,我目前正在用Python开发一个插件,该插件使用Webhook从bitbucket中提取关于开发人员在存储库上的活动(推、拉请求)的数据(有效负载)。在我的python脚本中,我试图访问修补程序和diffstat url(Bitbucket API)的内容,以提取有关文件更改的数据

以下是url的示例:

https://api.bitbucket.org/2.0/repositories/username/projectname/patch/cac0848613fea833316fcf7d87da9f80a5a2174e

https://api.bitbucket.org/2.0/repositories/username/projectname/diffstat/c6899a0a271db82790bf57de35dbbafb099417e4

但是当存储库是私有的时,我无法访问这些网页的内容。如果所有者将private更改为public,则一切正常,但出于隐私考虑,他无法更改,因此我的问题是,如何使用身份验证访问python脚本中的这些url?知道我对存储库具有写访问权限,如何通过脚本python进行身份验证

谢谢,


Tags: 数据httpsorg脚本插件身份验证apiurl
1条回答
网友
1楼 · 发布于 2024-05-01 22:11:52

你可能需要一个代币。从the bitbucket docs

Creating personal access tokens

To create a personal access token:

  1. Go to Profile picture > Manage account > Personal access tokens.
  2. Click Create a token.
  3. Set the token name, permissions, and expiry.

相关问题 更多 >