Authentication With Imgur API
So I'm writing a simple-ish script that can automatically download images from Imgur. I've come across the Imgur API but am struggling to get it to work. I registered an app but am not sure how to use it to be able to get information about images or albums. I do not want to be able to log in as a user or anything like that - just provide a URL of an album or a single image and be able to download it.
I've read that if I want to do this then I don't need to use the oauth stuff, I should just be able to use a client ID.
https://www.reddit.com/r/learnprogramming/comments/2uzxfv/how_do_i_get_fully_authenticated_to_use_imgurs_api/
The script I am writing is using Python, but just to test out the API I am typing the URL into the browser. If I go to the following URL:
https://api.imgur.com/3/album/qTt8G?client_id=MY_CLIENT_ID
Then I receive the following response:
{"data":{"error":"Authentication required","request":"/3/album/qTt8G","method":"GET"},"success":false,"status":401}
The full album URL is https://imgur.com/a/qTt8G I've tried reading through the API docs, but am stuck with this.
Useful info:
https://api.imgur.com/oauth2
https://api.imgur.com/endpoints/album
In the end I just used the Imgur API helper that is available on Github to do all the work. Just needed to provide the client ID and secret.
https://github.com/Imgur/imgurpython
链接地址: http://www.djcxy.com/p/81448.html下一篇: 使用Imgur API进行身份验证