-
Notifications
You must be signed in to change notification settings - Fork 98
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
Forbidden, when request event detail with GET #459
Comments
I do know that i.e. Zimbra does give error messages when trying to fetch event information through a simple GET. What is missing from the issue description here is python code using the python caldav library. I have a branch
(you may need to replace the username and password above) |
after checkout to server_checker, install niquests, and execute check_server_compatibility.py, i entered pdb, with a c (continue), i got an error. D:\work\zhangjiang\meeting_manage\caldav\caldav\__init__.py:10: UserWarning: You need to install the `build` package and do a `python -m build` to get caldav.__version__ set correctly
warnings.warn(
WARNING: this script is not production-ready
--Return--
> d:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py(84)_debugger()->None
-> pdb.set_trace()
(Pdb) c
Traceback (most recent call last):
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 134, in _try_make_calendar
cal = self.principal.make_calendar(cal_id=cal_id, **kwargs)
^^^^^^^^^^^^^^
AttributeError: 'ServerQuirkChecker' object has no attribute 'principal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 959, in <module>
check_server_compatibility()
File "c:\python312\Lib\site-packages\click\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 953, in check_server_compatibility
obj.check_all()
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 856, in check_all
self.check_mkcalendar()
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 255, in check_mkcalendar
makeret = self._try_make_calendar(name="Yep", cal_id="pythoncaldav-test")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 158, in _try_make_calendar
cal = self.principal.calendar(cal_id=cal_id)
^^^^^^^^^^^^^^
AttributeError: 'ServerQuirkChecker' object has no attribute 'principal' seems there's someting missing? |
Did you set the |
thanks, i just tried the new tool. and i noticed if i enter http://caldav.feishu.cn it will give me the same error AttributeError: 'ServerQuirkChecker' object has no attribute 'principal' then i changed to https://caldav.feishu.cn, it gave me the same error i encounter. :\work\zhangjiang\meeting_manage\caldav\caldav\__init__.py:10: UserWarning: You need to install the `build` package and do a `python -m build` to get caldav.__version__ set correctly
warnings.warn(
WARNING: this script is not production-ready
Traceback (most recent call last):
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 958, in <module>
check_server_compatibility()
File "c:\python312\Lib\site-packages\click\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 952, in check_server_compatibility
obj.check_all()
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 856, in check_all
self._fix_cal()
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 290, in _fix_cal
if cal.events() or cal.todos():
^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 1700, in events
return self.search(comp_class=Event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 1256, in search
o.load(only_if_unloaded=True)
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 2354, in load
r = self.client.request(str(self.url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\davclient.py", line 775, in request
raise error.AuthorizationError(url=str(url_obj), reason=reason)
caldav.lib.error.AuthorizationError: AuthorizationError at 'https://caldav.feishu.cn:443/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/3159df07-4569-4047-8579-be4d4e543be9.ics', reason Forbidden i'm pretty sure the url and username, password is correct |
This is interesting. The server does tell that the event exists, but it does not reveal the details about the event, and when the caldav library goes back asking for the details the server says "no, you're not permitted to view this". Hm. And you're able to access it through apple calendar client? And the apple calendar client is talking caldav? I do wonder how Apple gets any information out from this calendar. Could you try to do a |
The event on the calendar does not exist and does not contain any data. Perhaps it was deleted.
So the caldav library should not try to get any information about it. This is indeed a bug in the caldav library, thanks for pointing it out. I will try to find a solution to this. |
sorry, I may have expressed it wrongly. I mean, with the same url/username/password, I can subscribe this caldav server to apple calendar, and it syncd all the event to my apple calendar with no error. by the way, the server company suggest using davx5(an android webdav app)on android system. so i guess, this calendar can be add to davx5 as well. |
I did some research on the code. if i search event between 1206-1207(which i guess should return event in 1206) for calendar in calendars:
if calendar.id == '66A3A496-9B15-8003-66A3-A4969B158003':
events_fetched = calendar.search(
start=datetime(date.today().year, 12, 6),
end=datetime(date.today().year, 12, 7),
expand=True,
) the xml response is as follow。 there's 5 event, and on my calendar, there's 5 event(not deleted). so i guess the events are correct, but maybe the server return status in another way? <?xml version="1.0" encoding="UTF-8"?>
<D:multistatus xmlns:D="DAV:"
xmlns:C="urn:ietf:params:xml:ns:caldav"
xmlns:CS="http://calendarserver.org/ns/"
xmlns:ICAL="http://apple.com/ns/ical/"
xmlns:ME="http://me.com/_namespace/">
<D:response>
<D:href>/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/ff404e03-fd3d-4094-903f-882013e3dc1e.ics</D:href>
<D:propstat>
<D:prop>
<C:calendar-data/>
</D:prop>
<D:status>HTTP/1.1 404 Not Found</D:status>
</D:propstat>
</D:response>
<D:response>
<D:href>/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/b1fe7af0-1956-400a-8828-0d014a088f99.ics</D:href>
<D:propstat>
<D:prop>
<C:calendar-data/>
</D:prop>
<D:status>HTTP/1.1 404 Not Found</D:status>
</D:propstat>
</D:response>
<D:response>
<D:href>/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/804d50aa-cafc-4603-b553-95d806836d90.ics</D:href>
<D:propstat>
<D:prop>
<C:calendar-data/>
</D:prop>
<D:status>HTTP/1.1 404 Not Found</D:status>
</D:propstat>
</D:response>
<D:response>
<D:href>/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/391293c8-8e72-4173-aede-4d7fa78e622d.ics</D:href>
<D:propstat>
<D:prop>
<C:calendar-data/>
</D:prop>
<D:status>HTTP/1.1 404 Not Found</D:status>
</D:propstat>
</D:response>
</D:multistatus> |
this time, i got a lot of Forbidden error, it seems i requested a lot of ics. but the last error was different. CRITICAL:root:Server does not want to reveal details about the calendar object
Traceback (most recent call last):
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 1257, in search
o.load(only_if_unloaded=True)
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 2358, in load
r = self.client.request(str(self.url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\davclient.py", line 775, in request
raise error.AuthorizationError(url=str(url_obj), reason=reason)
caldav.lib.error.AuthorizationError: AuthorizationError at 'https://caldav.feishu.cn:443/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/3f40a5eb-d339-491b-adf3-46c54ca4e0a6.ics', reason Forbidden
CRITICAL:root:Server does not want to reveal details about the calendar object
Traceback (most recent call last):
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 1257, in search
o.load(only_if_unloaded=True)
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 2358, in load
r = self.client.request(str(self.url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\davclient.py", line 775, in request
raise error.AuthorizationError(url=str(url_obj), reason=reason)
caldav.lib.error.AuthorizationError: AuthorizationError at 'https://caldav.feishu.cn:443/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/6f7f2ea2-d1fc-4bd5-b58a-841ea194268a.ics', reason Forbidden
Traceback (most recent call last):
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 958, in <module>
check_server_compatibility()
File "c:\python312\Lib\site-packages\click\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python312\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 952, in check_server_compatibility
obj.check_all()
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 858, in check_all
self.check_event()
File "D:\work\zhangjiang\meeting_manage\caldav\check_server_compatibility.py", line 376, in check_event
obj1 = cal.add_event(
^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 871, in save_event
e.save(no_overwrite=no_overwrite, no_create=no_create, obj_type="event")
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 2567, in save
self._create(id=self.id, path=path)
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 2435, in _create
self._put()
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 2426, in _put
return self._put(False)
^^^^^^^^^^^^^^^^
File "D:\work\zhangjiang\meeting_manage\caldav\caldav\objects.py", line 2428, in _put
raise error.PutError(errmsg(r))
caldav.lib.error.PutError: PutError at '409 Conflict
', reason no reason |
This is very strange. So there exists five events, and they are not deleted. When asking the server for all the events, it gives empty calendar data and says "404 not found". When asking the server for the data for a particular event, it gives "403 forbidden" (instead of "404 not found"). I would assume that "404 not found" means the event was deleted from the server. If one has a copy of the calendar and wants to sync it towards the server, then it's important to get a notice on the deleted events. Returning the calendar URL and a 404 is (as far as I know) the standard way of doing so. In davx5, it's possible to turn on debug logging, then it will provide a zip-file with detailed logs, including the full communication. Could you try to figure out how davx5 goes around to finding the event data? |
ok, i guess i need to try run android app on windows |
I do see that I do have some logic for filtering out 404s ( The I think it would be very useful if it's possible to create a test account for me at that server, so I can run tests and debug myself. |
I went to https://feishu.cn and got redirected to larksuite.com - I'll try to register up for a free test account there. |
feishu is an app in China, and lark is the global version, I thisk they are basically the same. in this case I only use the calendar function. if you need any help, feel free to ask. |
I get to Lark and it requires me to install an app. Is this the correct? I will probably continue looking into this tomorrow. |
Ah, I found the button for "Lark web". And I even found "CalDAV settings". |
I can reproduce the problems with the larksuite. 409 if I try to insert an event or a task to the calendar, no data except the URL and a 404 status when trying to fetch a list with one event. I do have davx5 on my phone, so I will see if it works there. |
On davx5, the calendar comes up as "Read-only (by server)" |
davx5 is able to read the events from the calendar. There are some few differences in their report request. I'm looking into it. |
So davx5 sends this (added some whitespace for clarity):
In human language: "give me all events after 20240907T1858, and give me the etags". Server responds:
In human language: "We have found an item for you" Logs states: Found remote resource: 7f6d5b52-6c84-4f6a-b109-c6c1cc9f2581.ics Client goes back:
So rather than doing a GET towards the server, it's doing a search for an event with the given URL. Clever. "Give me contenttype, etag, schedule-tag and calendar data". And the server responds:
|
I've made a workaround in a new branch issue459 The compatibility checker script won't work out when the caldav server is read-only. |
Could you confirm that you can read out your events when using branch issue459 ? |
sorry for the delay. |
is there a good way to fetch the detail info of a event? like the attendees and so on. |
You can use things like |
I got a caldav server, and connect to it via apple calendar, it works fine with basic username and password auth.
when i try to connect it via python-caldav, I can go through the auth part and get all the calendars.
url: https://caldav.feishu.cn/
method: PROPFIND
headers: {'User-Agent': 'python-caldav/1.4.0', 'Content-Type': 'text/xml', 'Accept': 'text/xml, text/calendar', 'Depth': '0'}
body:
I can also get possibly the event_id via REPORT.
url: https://caldav.feishu.cn/u_ortn0136/66A3A496-9B15-8003-66A3-A4969B158003/
method: REPORT
headers: {'User-Agent': 'python-caldav/1.4.0', 'Content-Type': 'application/xml; charset="utf-8"', 'Accept': 'text/xml, text/calendar', 'Depth': '1'}
body:
but when it comes to detailed info via GET, it fails with reason Forbidden
I don't know how to continue the debug, and want to get some ideas, thanks in advance
The text was updated successfully, but these errors were encountered: