Re: Open a url with user and password
On 2014-12-07 11:48, Hossein Rashnoo wrote: Please help me. this is quite unrelated to django, maybe it would be better asking this question on the python mailinglist[1] -- Florian [1] https://www.python.org/community/lists/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/82d1df1fcd1f0e219d3be04dd04e5a0e%40ist-total.org. For more options, visit https://groups.google.com/d/optout.
Re: Open a url with user and password
> Den 09/12/2014 kl. 14.39 skrev Collin Anderson : > My first guess is that it's using NTLM authentication instead of basic auth. > If you curl -i http://portal:8080/ what "authenticate" headers do you get? > > Also, you should consider upgrading to python 2.7 if you haven't :) And nobody should need to look at urllib code anymore, either :-) Use requests instead, and https://github.com/requests/requests-ntlm if you need NTLN authentication. Erik -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/49DA6B8A-5E0C-4994-955A-84C3865A3B0A%40cederstrand.dk. For more options, visit https://groups.google.com/d/optout.
Re: Open a url with user and password
Hi, My first guess is that it's using NTLM authentication instead of basic auth. If you curl -i http://portal:8080/ what "authenticate" headers do you get? Also, you should consider upgrading to python 2.7 if you haven't :) Collin On Sunday, December 7, 2014 5:48:02 AM UTC-5, Hossein Rashnoo wrote: > > I want to create a web-service for connection to sharepoint that do > something like create a list and ... > So at first step because we use sharepoint with local ip i want to check > if i can connect to our sharepoint portal via my server or not. > So i looking for something like : urllib2.urlopen("http://portal:8080/ > ").read() > and i found this code for test: > > import urllib.request# Create an OpenerDirector with support for Basic HTTP > Authentication...auth_handler = > urllib.request.HTTPBasicAuthHandler()auth_handler.add_password(realm='PDQ > Application', > uri='https://portal:8080/', > user='my username', > passwd='my password')opener = > urllib.request.build_opener(auth_handler)# ...and install it globally so it > can be used with > urlopen.urllib.request.install_opener(opener)urllib.request.urlopen('http://portal:8080/') > > But after last line i got this error: > > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen > return _opener.open(url, data, timeout) > File "/usr/lib64/python2.6/urllib2.py", line 397, in open > response = meth(req, response) > File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response > 'http', request, response, code, msg, hdrs) > File "/usr/lib64/python2.6/urllib2.py", line 435, in error > return self._call_chain(*args) > File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain > result = func(*args) > File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default > raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) > HTTPError: HTTP Error 401: Unauthorized > > Please help me. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ffcb3bbd-8903-4436-b81a-18319a6ec476%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Open a url with user and password
I want to create a web-service for connection to sharepoint that do something like create a list and ... So at first step because we use sharepoint with local ip i want to check if i can connect to our sharepoint portal via my server or not. So i looking for something like : urllib2.urlopen("http://portal:8080/";).read() and i found this code for test: import urllib.request# Create an OpenerDirector with support for Basic HTTP Authentication...auth_handler = urllib.request.HTTPBasicAuthHandler()auth_handler.add_password(realm='PDQ Application', uri='https://portal:8080/', user='my username', passwd='my password')opener = urllib.request.build_opener(auth_handler)# ...and install it globally so it can be used with urlopen.urllib.request.install_opener(opener)urllib.request.urlopen('http://portal:8080/') But after last line i got this error: Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib64/python2.6/urllib2.py", line 397, in open response = meth(req, response) File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib64/python2.6/urllib2.py", line 435, in error return self._call_chain(*args) File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain result = func(*args) File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) HTTPError: HTTP Error 401: Unauthorized Please help me. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/70d5031a-be70-4c51-b5eb-c75e821a251f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.