【问题标题】:404 response when requesting current user via post request(Oauth2)通过发布请求(Oauth2)请求当前用户时的 404 响应
【发布时间】:2022-01-22 01:52:28
【问题描述】:

我正在尝试查找有关该用户的更多信息,并查看了对某些人有所帮助的文档,但我被困住了,因为我在请求数据时不断收到 404 响应。我也尝试用 data1 var 翻转 headers2 var,但响应相同。 https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-users (这是我的文档米使用)

def info(token):
    data1 = {'Authorization':token}
    headers1 = {'Content-Type': 'application/x-www-form-urlencoded',"Authorization": "Bearer"}
    r = requests.post("https://api.coinbase.com/v2/user/", data=data1, headers=headers1)
    print(r)

【问题讨论】:

    标签: python coinbase-api


    【解决方案1】:

    请求应该是 get 而不是 post。令牌使用 Bearer [token]

    格式进入 Authorization 标头
     def info(token):
        headers1 = {
            "Content-Type": 'application/x-www-form-urlencoded',
            "Authorization": f"Bearer {token}"}
        r = requests.get("https://api.coinbase.com/v2/user/", headers=headers1)
        print(r)
    

    【讨论】:

      猜你喜欢
      • 2022-01-04
      • 2018-10-03
      • 1970-01-01
      • 2021-10-01
      • 2016-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多