tobixen / calendar-cli

Simple command-line CalDav client, for adding and browsing calendar items, todo list items
GNU General Public License v3.0
247 stars 23 forks source link

Google calendar returns 405 #78

Closed tonimelisma closed 3 years ago

tonimelisma commented 3 years ago

Running calendar-cli --calendar-url "mycalendar" calendar agenda on Google calendar returns 405:

Traceback (most recent call last):
  File "/Users/tonimelisma/Development/calendar-cli/./calendar-cli.py", line 973, in <module>
    main()
  File "/Users/tonimelisma/Development/calendar-cli/./calendar-cli.py", line 964, in main
    return args.func(caldav_conn, args)
  File "/Users/tonimelisma/Development/calendar-cli/./calendar-cli.py", line 480, in calendar_agenda
    events_ = find_calendar(caldav_conn, args).date_search(dtstart, dtend, expand=True)
  File "/Users/tonimelisma/.local/share/virtualenvs/calendar-cli-xbVPV5m5/lib/python3.9/site-packages/caldav/objects.py", line 600, in date_search
    return self.search(root)
  File "/Users/tonimelisma/.local/share/virtualenvs/calendar-cli-xbVPV5m5/lib/python3.9/site-packages/caldav/objects.py", line 612, in search
    response = self._query(xml, 1, 'report')
  File "/Users/tonimelisma/.local/share/virtualenvs/calendar-cli-xbVPV5m5/lib/python3.9/site-packages/caldav/objects.py", line 171, in _query
    raise error.exception_by_method[query_method](errmsg(ret))
caldav.lib.error.ReportError: 405 Method Not Allowed

b'Not allowed'

Caldav URL is https://www.google.com/calendar/dav/first.last%40gmail.com/events

Running the latest cloned repo as of today, on macOS 11.0 and Python 3.9

tobixen commented 3 years ago

I will look into it, perhaps tomorrow

tobixen commented 3 years ago

... "perhaps tomorrow", right.

I'm looking into this now, managed to log into my old google account. First of all, https://www.google.com/calendar/dav/first.last%40gmail.com/events is probably not the caldav URL, that's the calendar URL. The caldav URL is just https://www.google.com/calendar/dav/. I configured up the caldav_url, caldav_user and caldav_pass and ran "./calendar-cli calendar agenda".

First problem, google blocked me because I was using a "non-google-native app".

Second problem, google blocks calendar-cli because it "doesn't meet our security standards". I was allowed to turn on access, but Google really doesn't like it. I should probably look into that at some point.

Third problem ... a traceback ending with AttributeError: '_tzicalvtz' object has no attribute 'localize'.

I'm looking more into it.

(there is also a google calendar cli ... search for gcalcli, probably it's more suitable if you know you will stick with google calendar and never use anything else).

tobixen commented 3 years ago

Next issue, for repeating events (i.e. a repeating birthday with dtstart set to the year of birth), the start date of the first event is shown rather than the start date of the upcoming ocurrence.

Except for that, I'm able both to add and list events, so I'm unable to reproduce the issue.

Could you check if it works for you also, if you reconfigure it to use the shorter caldav_url (just https://www.google.com/calendar/dav/)?

tobixen commented 3 years ago

Next issue, for repeating events (i.e. a repeating birthday with dtstart set to the year of birth), the start date of the first event is shown rather than the start date of the upcoming ocurrence.

Seems to be a Google issue ... I could not reproduce that with my private calendar.

tobixen commented 3 years ago

"Works For Me". I'll close this issue as for now. Let me know if you still are having issues, then we'll just reopen it.

tobixen commented 3 years ago

I just found this:

The old endpoint https://www.google.com/calendar/dav is deprecated and no longer supported; use it at your own risk. We recommend you transition to the new endpoint format described above.

ref https://developers.google.com/calendar/caldav/v2/guide

According to the instructions there one is supposed to use OAuth to access the Google calendar. Unfortunately calendar-cli does not support OAuth as for now. I'll make a separate task for it, but it will definitively not be completed this year :-)