P
Pascal
Hello,
I want to acces my OWA (Outlook Web Acces - http Exchange interface)
server with urllib2 but, when I try, I've always a 401 http error.
Can someone help me (and us)?
Thanks.
here's my pyscript:
( Python 2.3.3 (#1, Apr 6 2004, 01:47:39) - [GCC 3.3.3 (SuSE Linux)]
on linux2 )
************************************************************************
#! /usr/bin/python
import urllib2
# set authentification
auth = urllib2.HTTPBasicAuthHandler()
auth.add_password('owa.mydomain', 'http://owa.mydomain/',
'**USERNAME**', '**PASSWORD**')
# don't use proxy
prox = urllib2.ProxyHandler({})
# installation
opener = urllib2.build_opener(prox, auth)
urllib2.install_opener(opener)
# start
url = urllib2.urlopen('http://owa.mydomain/exchange/')
print url.readlines()
************************************************************************
here's the traceback:
************************************************************************
File "./owa.py", line 22, in ?
url = urllib2.urlopen('http://owa.mydomain/exchange/')
File "/usr/lib/python2.3/urllib2.py", line 129, in urlopen
return _opener.open(url, data)
File "/usr/lib/python2.3/urllib2.py", line 326, in open
'_open', req)
File "/usr/lib/python2.3/urllib2.py", line 306, in _call_chain
result = func(*args)
File "/usr/lib/python2.3/urllib2.py", line 901, in http_open
return self.do_open(httplib.HTTP, req)
File "/usr/lib/python2.3/urllib2.py", line 895, in do_open
return self.parent.error('http', req, fp, code, msg, hdrs)
File "/usr/lib/python2.3/urllib2.py", line 352, in error
return self._call_chain(*args)
File "/usr/lib/python2.3/urllib2.py", line 306, in _call_chain
result = func(*args)
File "/usr/lib/python2.3/urllib2.py", line 412, in
http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Accès refusé
************************************************************************
here's the LiveHTTPheaders/Firefox debug:
( the web page is well delivered )
************************************************************************
http://owa.mydomain/exchange/
GET /exchange/ HTTP/1.1
Host: owa.mydomain
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040804 Firefox/0.9.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.x 401 Accès refusé
Server: Microsoft-IIS/5.0
Date: Thu, 23 Sep 2004 08:56:03 GMT
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="owa.mydomain"
Connection: close
Content-Length: 21
Content-Type: text/html
GET /exchange/ HTTP/1.1
Host: owa.mydomain
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040804 Firefox/0.9.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Authorization: Basic CGFYZW50CDPOC3FTEXAQKG==
HTTP/1.x 200 OK
Server: Microsoft-IIS/5.0
Date: Thu, 23 Sep 2004 08:56:15 GMT
Set-Cookie: sessionid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,0x409;
path=/exchange/
Content-Type: text/html
Content-Length: 1071
MS-WebStorage: 6.0.6249
Cache-Control: no-cache
************************************************************************
I want to acces my OWA (Outlook Web Acces - http Exchange interface)
server with urllib2 but, when I try, I've always a 401 http error.
Can someone help me (and us)?
Thanks.
here's my pyscript:
( Python 2.3.3 (#1, Apr 6 2004, 01:47:39) - [GCC 3.3.3 (SuSE Linux)]
on linux2 )
************************************************************************
#! /usr/bin/python
import urllib2
# set authentification
auth = urllib2.HTTPBasicAuthHandler()
auth.add_password('owa.mydomain', 'http://owa.mydomain/',
'**USERNAME**', '**PASSWORD**')
# don't use proxy
prox = urllib2.ProxyHandler({})
# installation
opener = urllib2.build_opener(prox, auth)
urllib2.install_opener(opener)
# start
url = urllib2.urlopen('http://owa.mydomain/exchange/')
print url.readlines()
************************************************************************
here's the traceback:
************************************************************************
Traceback (most recent call last):./owa.py
File "./owa.py", line 22, in ?
url = urllib2.urlopen('http://owa.mydomain/exchange/')
File "/usr/lib/python2.3/urllib2.py", line 129, in urlopen
return _opener.open(url, data)
File "/usr/lib/python2.3/urllib2.py", line 326, in open
'_open', req)
File "/usr/lib/python2.3/urllib2.py", line 306, in _call_chain
result = func(*args)
File "/usr/lib/python2.3/urllib2.py", line 901, in http_open
return self.do_open(httplib.HTTP, req)
File "/usr/lib/python2.3/urllib2.py", line 895, in do_open
return self.parent.error('http', req, fp, code, msg, hdrs)
File "/usr/lib/python2.3/urllib2.py", line 352, in error
return self._call_chain(*args)
File "/usr/lib/python2.3/urllib2.py", line 306, in _call_chain
result = func(*args)
File "/usr/lib/python2.3/urllib2.py", line 412, in
http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Accès refusé
************************************************************************
here's the LiveHTTPheaders/Firefox debug:
( the web page is well delivered )
************************************************************************
http://owa.mydomain/exchange/
GET /exchange/ HTTP/1.1
Host: owa.mydomain
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040804 Firefox/0.9.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.x 401 Accès refusé
Server: Microsoft-IIS/5.0
Date: Thu, 23 Sep 2004 08:56:03 GMT
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="owa.mydomain"
Connection: close
Content-Length: 21
Content-Type: text/html
GET /exchange/ HTTP/1.1
Host: owa.mydomain
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040804 Firefox/0.9.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Authorization: Basic CGFYZW50CDPOC3FTEXAQKG==
HTTP/1.x 200 OK
Server: Microsoft-IIS/5.0
Date: Thu, 23 Sep 2004 08:56:15 GMT
Set-Cookie: sessionid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,0x409;
path=/exchange/
Content-Type: text/html
Content-Length: 1071
MS-WebStorage: 6.0.6249
Cache-Control: no-cache
************************************************************************