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

Access denied. You must have write or admin access

亲爱的 Whosebug 社区,我目前正在开发一个带有 Python 的插件,它使用 webhooks 从 bitbucket 的存储库(推送、拉取请求)中提取有关开发人员 activity 的数据(有效负载)。在我的 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 知道我对存储库具有写入权限?

谢谢,

您可能需要一个令牌。来自 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.