403 error while getting data from Imgur api. Where am I going wrong?

From the imgur api page:

For public read-only and anonymous resources, such as getting image info, looking up user comments, creating an anonymous album, etc. all you need to do is send an authorization header with your client_id along with your requests. This also works if you'd like to upload images anonymously (without the image being tied to an account). This lets us know which application is accessing the API.

This is my request using python-requests:

 payload = {"Client-ID":"my client id"}
 r=requests.get("https://api.imgur.com/3/account/imgur/images/0.json?perPage=42&page=6", data = payload,headers={"content-type":"text"},verify=False)

I'm getting a 403 error. All I want to do is retrieve images. Nothing to do with user information, so no need of Oauth2. Where am I going wrong?


It looks like you're sending your Client-ID as your request body. The documentation says it needs to be in the Authorization header.

headers = {"Content-Type": "text", "Authorization": "Client-ID YOUR_CLIENT_ID"}
r = requests.get("https://...", headers=headers, verify=False)
链接地址: http://www.djcxy.com/p/81436.html

上一篇: AFNetworking 2.0和授权Imgur API

下一篇: 从Imgur api获取数据时出现403错误。 我哪里错了?