Search code examples
pythonpython-2.7python-requestsimgur

Getting "Permission Denied" response while using ImgurAPI


I'm using this code to get data about an Imgur Image. I assume this doesn't require Oauth2 excepts the client ID in the header.

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);

However, I'm receiving "Permission Denied" error. Does it require access_token or something?


Solution

  • Using requests.get instead of requests.post solved the issue. Fixed code.

    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);