nausheenfatma / python-wikitools

Automatically exported from code.google.com/p/python-wikitools
0 stars 0 forks source link

HTTP Error 401: Authorization Required #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I'm using mediawiki behind a private server with an .htaccess file inside 
mediawiki source directory. When I try to use wikitools I get the following 
error:

>>> from wikitools import wiki
>>> from wikitools import api
>>> site = wiki.Wiki("http://myserver/mw/api.php")
HTTPError: HTTP Error 401: Authorization Required trying request again in 5 
seconds
HTTPError: HTTP Error 401: Authorization Required trying request again in 10 
seconds
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "wikitools/wiki.py", line 79, in __init__
    self.setSiteinfo()
  File "wikitools/wiki.py", line 97, in setSiteinfo
    info = req.query()
  File "wikitools/api.py", line 139, in query
    rawdata = self.__getRaw()
  File "wikitools/api.py", line 224, in __getRaw
    time.sleep(self.sleep+0.5)
KeyboardInterrupt
>>> 

What is the expected output? What do you see instead?
Is there any way to specify an username/password? I think I could modify the 
code when urllib is called but I would like to know if there is any login 
mechanism. It's the first time I'm using mw clients to automatize tasks. Any 
help is welcome. Thanks.

What version of the product are you using? On what operating system?
wikitools-1.1.1
Python 2.6.6
debian 6.0

Original issue reported on code.google.com by kaska...@gmail.com on 5 May 2011 at 2:21

GoogleCodeExporter commented 8 years ago
At the moment the only login methods supported are the standard method and 
LDAP. HTTP Auth may be supported in a future release but isn't currently.

Original comment by MrZmanwiki@gmail.com on 5 May 2011 at 2:40

GoogleCodeExporter commented 8 years ago

Original comment by MrZmanwiki@gmail.com on 8 Jun 2011 at 11:05

GoogleCodeExporter commented 8 years ago
I have created a patch to add this feature. If you need HTTP auth, simply add 
the credentials in the URL like 
"http://username:password@mywiki.site/w/api.php".

Original comment by vegardha...@gmail.com on 24 Oct 2011 at 1:25

GoogleCodeExporter commented 8 years ago
Couldn't see that the file was added.. I'm giving it another go.

Original comment by vegardha...@gmail.com on 24 Oct 2011 at 1:30

Attachments:

GoogleCodeExporter commented 8 years ago
Ah, I didn't see this thread.  I also have created a patch for this issue.  I 
added two optional arguments to the Wiki object for server username and 
password.

It would work like this:
site = wiki.Wiki("https://wiki.blah.com/path/api.php",'username')
-> will prompt for password in this case

or

site = wiki.Wiki("https://wiki.blah.com/path/api.php",'username','password')

I'll leave it to the maintainers to look at the patches, maybe the one above is 
better, I don't know.  I figured I should post it since I did it.

Original comment by rdbu...@gmail.com on 29 May 2012 at 6:25

Attachments:

GoogleCodeExporter commented 8 years ago
Done in 
https://github.com/alexz-enwp/wikitools/commit/983b6dcc5d1389ba45d43cda5df9ab11f
4caed7a

I don't have a wiki behind HTTP Auth, so I haven't actually tested it besides 
ensuring it didn't break normal usage.

Original comment by MrZmanwiki@gmail.com on 7 Dec 2013 at 11:16