代码之家  ›  专栏  ›  技术社区  ›  Zinou Ayachi

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

  •  1
  • Zinou Ayachi  · 技术社区  · 8 年前

    什么是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'))
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Andy    8 年前

    这种身份验证非常常见,请求文档 covers

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

    您需要删除 -u PASSWORD: 从目的地出发。

    另一种方法是使用 streak_client PiPY上的包或 GitHub