kidd / org-gcal.el

Org sync with Google Calendar. (active maintained project as of 2019-11-06)
436 stars 47 forks source link

Maximum number of fetched events #23

Open fgilbert68 opened 5 years ago

fgilbert68 commented 5 years ago

Hi.

First, thanks to Kidd and other contributors for keeping this tool alive, and going on maintaining and improving it.

Second, after fiddling a good while with Google Developers Console, I succeeded in having some OAuth2 enabled client ID linked with some kind or Google Calendar API access rights, and I was successfully able to use org-gcal. So I can tell it works, but I am not sure that the howto in the GitHub main page was very helpful, or very up to date with OAuth2 requirements.

My main subject here is that I wanted to fetch a full copy of my Google calendars, going back to 15+ years in the past. Customizing org-gcal-up-days value, I was able to do that, but my calendars were truncated. I realized they were truncated to 250 events, which is the default maximum for the Google "events" API.

So I modified org-gcal.el in the following way:

*** org-gcal.el.bak 2018-10-17 18:04:27.075325427 +0200
--- org-gcal.el 2018-10-17 18:36:05.671930744 +0200
***************
*** 160,165 ****
--- 160,166 ----
                            ("key" . ,org-gcal-client-secret)
                            ("singleEvents" . "True")
                            ("orderBy" . "startTime")
+                           ("maxResults" . 2500)
                            ("timeMin" . ,(org-gcal--subtract-time))
                            ("timeMax" . ,(org-gcal--add-time))
                            ("grant_type" . "authorization_code"))

And then I was able to fetch all events, even with 2500 being obviously the biggest maximum value allowed for the API. Maybe that could be incorporated to the org-cal release, or maybe even in a nicer way using another defcustom value.

kidd commented 5 years ago

Hi @fgilbert68!

Thanks for using org-gcal and for the feedback. I'd happily merge a pull request adding a defcustom with the max-results.

Also, feel free to contribute to the explanation in the readme. AFAIR, the process it describes is the correct one, but a maybe we could use nicer wording.