On Thu, Oct 18, 2012 at 6:55 PM, django <maitre...@gmail.com> wrote:

> I am trying to create a Django app, one of the thing I do in that is write
> a connection.py which connects to  a remote server. In that connection
> string I need to send one of the parameter as "http_auth =
> http_auth.HTTPBasicAuth(user, password)". I am not sure how to do that in
> Django. I searched the web a lot and nothing I got which is very relevant
> to what I am doing. Can anyone please help me.


If I understand you correctly, you want to connect to a service that uses
HTTP Basic Auth in connection.py and do something with the data.

You might look into python's urllib2 library.

I found this snippet:

import urllib2, base64

request = urllib2.Request("http://api.foursquare.com/v1/user";)

base64string = base64.encodestring('%s:%s' % (username,
password)).replace('\n', '')

request.add_header("Authorization", "Basic %s" % base64string)

result = urllib2.urlopen(request)

Here:
http://stackoverflow.com/questions/635113/python-urllib2-basic-http-authentication-and-tr-im


-A

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to