【问题标题】:Web API Requests AuthenticationWeb API 请求身份验证
【发布时间】:2021-06-30 14:01:40
【问题描述】:

我正在使用以下 API 信息尝试获取请求:

https://github.com/iblockin/pool_web_api_doc/blob/master/api_en.md

谁能帮我看看标题应该是什么样子,或者指出我在哪里搞砸了?我不断收到未经身份验证的回复。

url = "https://api-prod.poolin.com/api/public/v1/subaccount"

r = requests.get(url, headers =  {'authorization': 'accessToken tokenhere'})

如果在其他 1000 个地方不可避免地回答了这个问题,请提前道歉。

这里是严重的菜鸟,正在努力学习

【问题讨论】:

  • 您是在 accessToken 之外添加令牌还是在执行您提供的代码?
  • @SamirAhmane 我正在用我的令牌替换,仍然收到“未验证”
  • 我认为您应该根据文档将 accessToken 更改为 Bearer

标签: python python-requests request-headers


【解决方案1】:

使用这个

url = "https://api-prod.poolin.com/api/public/v1/subaccount"

r = requests.get(url, headers = {'authorization': 'Bearer tokenhere'})

如前所述,hereaccessToken 应该在headeras 中传递

{'authorization':'Bearer TOKEN'} # TOKEN is replaced with the token value to be transmitted

因此请相应地更正您的代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-21
    • 2023-03-24
    • 2017-12-30
    • 2014-09-14
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 2011-10-21
    相关资源
    最近更新 更多