【问题标题】:Getting "Permission Denied" response while using ImgurAPI使用 ImgurAPI 时获得“权限被拒绝”响应
【发布时间】:2016-03-05 13:00:56
【问题描述】:

我正在使用此代码获取有关 Imgur 图像的数据。我认为这不需要 Oauth2,但标头中的客户端 ID 除外。

import requests
client_id = '<my_client_id>'
header = {"Authorization": "Client-ID " + client_id};

r = requests.post("https://api.imgur.com/3/image/WPYW1pE", headers=header);
r = r.json();
print(r);

但是,我收到“权限被拒绝”错误。是否需要 access_token 之类的?

【问题讨论】:

    标签: python python-2.7 python-requests imgur


    【解决方案1】:

    使用 requests.get 而不是 requests.post 解决了这个问题。固定代码。

    import requests
    client_id = '<my_client_id>'
    header = {"Authorization": "Client-ID " + client_id};
    
    r = requests.get("https://api.imgur.com/3/image/WPYW1pE", headers=header);
    r = r.json();
    print(r);
    

    【讨论】:

      猜你喜欢
      • 2018-11-12
      • 1970-01-01
      • 2021-01-21
      • 2014-10-09
      • 1970-01-01
      • 2018-11-05
      • 2016-06-18
      • 1970-01-01
      • 2011-03-29
      相关资源
      最近更新 更多