0

I'm trying to implement an OAuth2 authentication server and for the client part i wanted to send a json request to the server (from a Django view) and i found several libraries to do that tho' the most common are httplib2 and urllib2 i was wondering which is the difference between them and which is the best library for this purpose.

Thanks in advance.

Edit: After searching, i found an extremely useful library called Requests and i use this one since then. (http://docs.python-requests.org/en/latest/)

CodeArtist
  • 5,534
  • 8
  • 40
  • 65
  • You can use an OAuth2 library like this: https://github.com/simplegeo/python-oauth2. Or one of django-oauth2 applications. – MostafaR Mar 28 '13 at 05:05
  • I'm confused, are you trying to implement an OAuth server, i.e. to be a provider, or are you trying to create views on a server, i.e. your Django app, that will consume OAuth providers, e.g. Facebook? – maxcountryman Mar 29 '13 at 01:45
  • i'm trying to implement an OAuth server (like facebook) and a demo client that connects to the server. Specifically this one i need it for the client. – CodeArtist Mar 29 '13 at 11:58
  • Related: [Should I use urllib or urllib2 or requests?](http://stackoverflow.com/questions/2018026) – DavidRR Jan 08 '15 at 15:38

1 Answers1

2

urllib2 handles opening and reading URLs. It also handles extra stuff like storing cookies.

httplib handles http requests, its what happens behind the curtain when you open a url.

you can send json request with urllib2 so you should use that. see this.

Community
  • 1
  • 1
Baconator507
  • 1,747
  • 2
  • 12
  • 20
  • thank you. Actually i found an amazing library called Requests (http://docs.python-requests.org/en/latest/) – CodeArtist May 20 '14 at 14:00
  • Also see: [Should I use urllib or urllib2 or requests?](http://stackoverflow.com/questions/2018026) – DavidRR Jan 08 '15 at 15:39