Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 401 when trying to do operations in shared folder that is password protected. #282

Open
Attackly opened this issue Jun 16, 2023 · 1 comment

Comments

@Attackly
Copy link

Attackly commented Jun 16, 2023

Hey,

when i want to access a password protected share like this

oc = owncloud.Client.from_public_link(theHost, folder_password=thepassword)
oc.list("")

I recive this error:

Traceback (most recent call last):
  File "C:\Users\me\PycharmProjects\pyocclienttest\main.py", line 4, in <module>
    oc.list("")
  File "C:\Users\me\PycharmProjects\pyocclienttest\venv\Lib\site-packages\owncloud\owncloud.py", line 469, in list
    res = self._make_dav_request('PROPFIND', path, headers=headers, data=data)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\PycharmProjects\pyocclienttest\venv\Lib\site-packages\owncloud\owncloud.py", line 1815, in _make_dav_request
    raise HTTPResponseError(res)
owncloud.owncloud.HTTPResponseError: HTTP error: 401

I have fiddled around a bit.
I got it to work by adding this header to the list and get_file function.
headers={"X-Requested-With" : "XMLHttpRequest"}

Does someone have the same problem or can confirm it?

@Jasonthefirst
Copy link

Jasonthefirst commented Dec 14, 2023

Hi,
How did you add the header? You mean you added the header to the source or can you give the header to the client? I have the same error to a publicly shared nextcloud folder.
Edit:
Found it: oc._session.headers.update({"X-Requested-With": "XMLHttpRequest"})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants