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 "<console>", line 1, in <module>
>   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.

Reply via email to