python - 尝试使用 Bitbucket Cloud API 进行身份验证时获取 401 代码
问题描述
得到下面的问题,我可以获得存储库,但是当我尝试获取提交时,即它失败并且我得到 401。回购和工作区是私有的,所以第一个会失败我想如果代码有问题完全。最近有人做过吗?
baseUrlv2 = "https://bitbucket.org/api/2.0"
role = "contributor"
username = {bitbucket_username}
password = {bitbucket_app_password}
r = requests.get("{base}/repositories/{workspace}?role={role}".format(base=baseUrlv2, role=role),
auth=(use
rname, password))
repos = r.json()
while 'next' in repos:
for repo in repos["values"]:
commitLink = repo["links"]["commits"]["href"]
repoSlug = repo["slug"]
#the request below seems to be the issue :\
r = requests.post((commitLink), auth=(username,password))
c = r.json() #this is where it breaks
解决方案
经过一堆试验和错误,其中 Atlassian 文档说使用您的 Bitbucket 用户名 + 应用程序密码.. 事实并非如此。您需要使用正常的电子邮件和密码才能实际使用 API。
Bitbucket 的 API 调用通常会出现一些奇怪的问题,但此问题已得到解决。
推荐阅读
- python-3.x - IndentationError::expected 一个缩进块
- angular - Angular + Jest + ChartJS - ReferenceError:图表未定义
- git - 用于 Windows Git 安装的可选 Unix 工具
- c# - SSRS 2016:将报表加载到服务器时出现 NullReferenceException 和 ReportServerException
- python-3.x - 如何优化此 python 代码以对大输入进行排序?
- ms-access - MS-Access 表单中的动态查询
- three.js - Aframe:多网格模型的 glTF 大小调整和重新居中
- java - 如何以编程方式阻止应用程序中的 chromecast / MHL 屏幕镜像?
- excel - VBA Worksheet_Change 如何隐藏其中具有特定值的行
- google-cloud-firestore - 如何配置 GatsbyJS firestore 插件。timestampsInSnapshots 更改