如何使用 Python 发送经过身份验证的 https 请求?

How do I send authenticated https requests using Python?

Python 等同于以下 curl 命令的是什么?

curl https://www.streak.com/api/v1/boxes/{Keyhere}/  -u passwordhere:

我试过了,但出现 400 错误:

requests.get('https://www.streak.com/api/v1/boxes/{Key}/threads -u PASSWORD:', auth=HTTPBasicAuth('USER', 'pass'))

这种类型的身份验证非常常见,并且请求文档 covers 它。

requests.get('https://www.streak.com/api/v1/boxes/{Key}/threads', auth=(YOUR_API_KEY, ''))

您需要从目的地中删除 -u PASSWORD:

另一种方法是使用 streak_client package on PiPY or GitHub