Accessing Imgur API with Python 3.4.1 and Urllib3 -


i trying wrap head around imgur api. have found examples of how send authorization header imgur, use urllib2, , apparently, using pyhton 3.4.1 can use urllib3.

so have tried couple of things , none of them seem working.

from this post tried using basic_auth header:

http = urllib3.poolmanager() header = urllib3.make_headers(basic_auth="client-id" + client_id) r = http.request('get', 'https://api.imgur.com/3/gallery/r/pics', headers=header) 

that gives me 403 error.

from this post tried method instead:

http = urllib3.poolmanager() header= {"content-type": "text", "authorization": "client-id" + client_id} r = http.request('get', 'https://api.imgur.com/3/gallery/r/pics', headers=header) 

that returns 403.

now have got step closer reading urllib3 documents , tried sending authorization field instead.

http = urllib3.poolmanager() r = http.request('get', 'https://api.imgur.com/3/gallery/r/pics', fields={"authorization": "client-id " + client_id}) 

this returns 401.

so can 1 me figure out basic anonymous interaction imgur api using these, or other methods?

per imgur's api documentation, have send auth header such:

authorization: client-id your_client_id 

in line:

header = urllib3.make_headers(basic_auth="client-id" + client_id) 

you sending as: authorization: client-idyour_client_id

you need space between.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -