XML RPC changes between 3.7 and 3.9 yield 401 http error
Chris Angelico
rosuav at gmail.com
Wed Feb 24 12:00:07 EST 2021
On Thu, Feb 25, 2021 at 2:02 AM lucas <lucas at bourneuf.net> wrote:
>
> Hi everyone,
>
> (Sorry for the double-send if any, i'm not sure the first send was
> performed, maybe because of bounce errors according to mailman.)
>
>
> I'm currently trying to understand an error when using the
> dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC
> interface.
>
> Another description of the problem :
> https://github.com/kynan/dokuwikixmlrpc/issues/8
>
> Here is the code, tailored to work with the DokuWiki RPC interface:
>
> from urllib.parse import urlencode
> import xmlrpc.client as xmlrpclib
>
> URL = 'wiki.example.net'
> USER = 'user'
> PASSWD = 'password'
> USER_AGENT = 'DokuWikiXMLRPC 1.0 for testing'
>
> script = '/lib/exe/xmlrpc.php'
> url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
> xmlrpclib.Transport.user_agent = USER_AGENT
> xmlrpclib.SafeTransport.user_agent = USER_AGENT
> proxy = xmlrpclib.ServerProxy(url)
>
> v = proxy.dokuwiki.getVersion()
> print(v)
>
> When ran with Python 3.7 (a personnal debian server, or a personal
> windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"'
> as ouput.
> When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
> following stacktrace:
>
> Traceback (most recent call last):
> File "/home/project/read.py", line 32, in <module>
> v = proxy.dokuwiki.getVersion()
> File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
> return self.__send(self.__name, args)
> File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
> response = self.__transport.request(
> File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
> return self.single_request(host, handler, request_body, verbose)
> File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
> single_request
> raise ProtocolError(
> xmlrpc.client.ProtocolError: <ProtocolError for
> wiki.example.net/lib/exe/xmlrpc.php: 401 Unauthorized>
>
A properly-formed URL will start with a protocol. I don't know
specifically what changed, but it's looking like something started
rejecting malformed URLs. Try adding "http://" or "https://" to your
URL (whichever is appropriate) and see if both versions will accept
it.
ChrisA
More information about the Python-list
mailing list