Skip to content
This repository was archived by the owner on Jun 15, 2018. It is now read-only.
This repository was archived by the owner on Jun 15, 2018. It is now read-only.

Connecting to mediawiki with basic-auth fails #9

Description

@dev-zero
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 251, in login
    return do_login(self, user, passwd)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 242, in do_login
    result = self.call(data)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 184, in call
    return json.loads(self._fetch_http(self._api_url, params))
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 153, in _fetch_http
    base64string = base64.encodestring(auth_str).replace('\n', '')
TypeError: expected bytes, bytearray or buffer compatible object

the problem is that the arguments passed to replace must be of the same type. So line 153 should read:

            base64string = base64.encodestring(auth_str).replace(b'\n', b'')

even after that change, the request fails:

  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 251, in login
    return do_login(self, user, passwd)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 242, in do_login
    result = self.call(data)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 184, in call
    return json.loads(self._fetch_http(self._api_url, params))
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 156, in _fetch_http
    response = self._opener.open(request)
  File "/usr/lib64/python3.3/urllib/request.py", line 475, in open
    response = meth(req, response)
  File "/usr/lib64/python3.3/urllib/request.py", line 587, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.3/urllib/request.py", line 513, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.3/urllib/request.py", line 447, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.3/urllib/request.py", line 595, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Authorization Required

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions