Git Product home page Git Product logo

org-gcal.el's Introduction

Org-Gcal https://melpa.org/packages/org-gcal-badge.svg https://github.com/kidd/org-gcal.el/actions/workflows/main.yml/badge.svg

org-gcal offers

  • Fetch google calendar event
  • Post/edit org element
  • Sync between Org and Gcal

Data will be UTF-8 encoded for sync.

Getting Started

Follow the instructions at Installation, and then run org-gcal-fetch to download Google Calendar events into your Org-mode files using the Google Calendar API. Run org-gcal-fetch to retrieve new events and update events already retrieved, and run org-gcal-post-at-point on an Org-mode headline corresponding to a downloaded event to push updates to the events on the Google Calendar API server.

First time setup: on the initial run, in order to obtain the initial OAuth authorization, org-gcal will open a link in the browser to obtain authorization for the OAuth credentials generated in Installation. You will probably see a screen that says “This app isn’t verified”. You will need to click on the “Advanced” link to authorize the application:

https://user-images.githubusercontent.com/44981227/71685532-d892ce00-2d98-11ea-8981-1adce23e8678.png

Requirements

Installation

WARNING: The steps described below stopped working on 28.02.2022 when Google deprecated the ability to retrieve OAuth 2.0 tokens via out-of-band redirect_uri. Please refer to #191 for more background and to track progress on resolving this issue.

  1. Go to Google Developers Console
  2. Create a project (with any name)
  3. Click on the project
  4. Click on the hamburger menu at the upper-left, then APIs & Services, then Credentials.
  5. Set up a consent screen. Give the application a name and set it up as type “external application”, and accept the defaults for everything else. You should not need to verify the application, because only your user will be using it.
  6. Once you’ve set up a consent screen (this is required), click on Create Credentials and Oauth client ID with Application type Desktop (or Other, if Desktop is not present).
  7. Click on Create Client ID
  8. Record the Client ID and Client secret for setup.
  9. Under the same APIs & Services menu section, select Library
  10. Scroll down to Calendar API. Click the Enable button to enable calendar API access to the app you created in steps 5 & 6.

    Go to Google setting page to check the calendar ID.

  11. Go to Google setting page and click the gear-shaped settings icon in the upper right, then select “Settings” from the drop down list.
  12. Select the “Setting for my Calendars” tab on the left, which will display a list of your calendars.
  13. Select the calendar you would like to synchronize with. This will take you to the “Calendar Settings” page for that calendar. Near the end is a section titled “Integrate Calendar”. Following the XML, ICAL, and HTML tags, you will see your Calendar ID.
  14. Copy the Calendar ID for use in the settings below, where you will use it as the first element in the org-gcal-fetch-file-alist for associating calendars with specific org files. You can associate different calendars with different org files, so repeat this for each calendar you want to use.

Setting example

(setq org-gcal-client-id "your-id-foo.apps.googleusercontent.com"
      org-gcal-client-secret "your-secret"
      org-gcal-fetch-file-alist '(("[email protected]" .  "~/schedule.org")
                                  ("[email protected]" .  "~/task.org")))
(require 'org-gcal)

Note

This package uses plstore as a dependency for storing OAuth tokens. In order to avoid getting prompted all the time for the password to your plstore, it is recommended that you put the following in your init.el:

(setq plstore-cache-passphrase-for-symmetric-encryption t)

Multiple accounts

There’s no support for multiple accounts. If you want to use org-gcal with calendars from different accounts, you can give permissions to the account you configured via the calendar’s settings interface.

To get more detailed information you can check this link.

Different timezone

If you local timezone is different from the Calendar. You can use your local timezone to fetch events. Event will be fetched using timezone defined in org-gcal-local-timezone. Timezone string can be found from: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.

Testing

To execute compile and regression tests, run make.

This will use your existing Emacs installation to generate a value of load-path that allows org-gcal to find all its dependencies, and save it to .load-path.el in this directory. To delete this and other temporary files, run make clean.

Usage

Getting started

Once you’ve set up the basic settings (see Setting example), you can run org-gcal-fetch to fetch events into the files configured in org-gcal-fetch-file-alist. After the initial fetch, running org-gcal-fetch will retrieve newly-created events and update already-fetched events.

To create a Google Calendar event from an Org-mode event, it’s enough to run the org-gcal-post-at-point command on a simple headline:

* Event title

This will prompt you for the calendar ID, start time, and end time of the event. Therefore, if you’d like to create an event without user interaction (from a template, for example), you should set these fields before running org-gcal-post-at-point:

* Event title
:PROPERTIES:
:calendar-id: [email protected]
:END:
:org-gcal:
<2020-07-15 wed 09:15-09:30>

Event details

(can be multiple paragraphs).
:END:

After the event has been created, some Google Calendar API-specific fields will be set for future updates to the event:

* Event title
:PROPERTIES:
:calendar-id: [email protected]
:ETag:     "7777777777980000"
:ID:       xxxxxxxxxxa4jlcj0v998f4u18/[email protected]
:END:
:org-gcal:
<2020-07-15 wed 09:15-09:30>

Event details

(can be multiple paragraphs).
:END:

If you want to schedule the event in your Org Agenda, you can use the SCHEDULED property (set by org-schedule) instead of storing the date in the :org-gcal: drawer. The drawer will still be present to contain event details:

* Event title
SCHEDULED: <2020-07-15 wed 09:15-09:30>
:PROPERTIES:
:calendar-id: [email protected]
:ETag:     "7777777777980000"
:ID:       xxxxxxxxxxa4jlcj0v998f4u18/[email protected]
:END:
:org-gcal:
Event details

(can be multiple paragraphs).
:END:

After editing an event in Org mode, you can also run org-gcal-post-at-point to update the event on Google Calendar. The command org-gcal-sync does what org-gcal-fetch does, but also runs org-gcal-post-at-point on all events that you’ve edited in Org mode to update the corresponding events in Google Calendar.

Event structure

org-gcal modifies the following Org-mode properties and drawers when updating an event from the Google Calendar API:

Title
contains the event summary (minus any TODO keywords or tags).
  • Timestamps:
    SCHEDULED
    if the SCHEDULED attribute of a headline is present, org-gcal will maintain the start and end times of an event there rather than in a timestamp in the org-gcal drawer (see below).
  • Properties:
    • calendar-id (can be modified using the =org-gcal-calendar-id-property= variable) :: contains the calendar ID of the calendar on which the event is maintained.
    • ETag (can be modified using the =org-gcal-etag-property= variable) :: contains the most recent ETag retrieved from the Google Calendar API for the event (see the Google Calendar API documentation). Used to support automatically updating the headline using the most recent event data from the API if it has changed on the server since it was last retrieved.

      **NOTE**: If the ETag property is present on a headline (even if empty (=”“=)) and not equal to the value stored by the Calendar API, your event will be **overwritten** with the data from the server. In this case, you’ll see a notification for a HTTP 512. This is intended behavior. If your event is being overwritten when you don’t want it, remove the ETag property from your headline.

    ID
    contains <event_id>/<calendar_id> of the event, as provided by the Google Calendar API. Don’t change the ID manually, or else the event won’t be able to retrieved or updated from the headline.
  • Drawers:
    org-gcal (can be modified using the =org-gcal-drawer-name= variable)
    contains the event description. Unless the timestamp is maintained using SCHEDULED, the initial line of this drawer contains the event start and end time, with the event description starting in the next paragraph.

Apart from these, all other attributes are preserved when an event is updated in any way.

Commands

org-gcal-fetch

Fetch Google calendar events for all calendar IDs in org-gcal-fetch-file-alist occurring between org-gcal-up-days before today and org-gcal-down-days after today. If the events have already been retrieved and can be located using their Org-mode headline IDs, update the event in place. Otherwise, insert it at the end of the file corresponding to the event’s calendar ID in org-gcal-fetch-file-alist. Does not update events on the server.

org-gcal-sync

Like org-gcal-fetch, but also update events on the server if they have changed locally.

org-gcal-fetch-buffer

Fetch changes to Google calendar events to update entries in the current buffer, but don’t update events on server.

org-gcal-sync-buffer

Sync entries in the current buffer with Google Calendar.

org-gcal-post-at-point

Update the event represented by the Org-mode headline at POINT on the server using the Google Calendar API.

If the event has changed on the server since it was last retrieved (detected using the ETag property), automatically update the headline using the event data from the server instead of updating the event on the server.

org-gcal-delete-at-point

Delete the event represented by the Org-mode headline at POINT on the server using the Google Calendar API. This will not delete the Org-mode headline.

If the event has changed on the server since it was last retrieved (detected using the ETag property), automatically update the headline using the event data from the server instead of updating the event on the server.

Deleting events

If an event is deleted on the server, then updating an event (via org-gcal-post-at-point, org-gcal-sync, etc.) will optionally cancel and delete the corresponding Org mode headlines:

  • org-gcal-update-cancelled-events-with-todo: if set (the default), mark all cancelled events with the org-gcal-cancelled-todo-keyword (default: CANCELLED). This keyword must be one defined in org-todo-keywords or it will be ignored.
  • org-gcal-remove-api-cancelled-events: if set, delete Org headlines of cancelled events. The default value is =’ask=, which means to prompt for deletion.
  • org-gcal-remove-events-with-cancelled-todo: by default, avoid deleting Org headlines of events that are marked with org-gcal-cancelled-todo-keyword beforehand, to allow preserving a headline for a cancelled event from being deleted. Setting this to t always deletes headlines, even already cancelled ones.

Other features

Minimize alerts

Modify org-gcal-notify-p from t to nil

Collect instances of recurring events under parent event

By default, org-gcal-recurring-events-mode is set to =’top-level=, which means that new fetched events that are instances of recurring events will be inserted at the top level of the file for the calendar ID configured in org-gcal-fetch-file-alist:

* Meeting
SCHEDULED: <2020-08-07 Fri 11:00>
* Meeting
SCHEDULED: <2020-08-14 Fri 11:00>
* Meeting
SCHEDULED: <2020-08-21 Fri 11:00>
* Meeting
SCHEDULED: <2020-08-28 Fri 11:00>

If org-gcal-recurring-events-mode is instead set to =’nested=, such events will be inserted as Org-mode child headlines under the headline for the parent event:

* Meeting
SCHEDULED: <2017-02-17 Fri 11:00>
** Meeting
SCHEDULED: <2020-08-07 Fri 11:00>
** Meeting
SCHEDULED: <2020-08-14 Fri 11:00>
** Meeting
SCHEDULED: <2020-08-21 Fri 11:00>
** Meeting
SCHEDULED: <2020-08-28 Fri 11:00>

Here the parent meeting has been running for several years, but only the instances of the meeting in the range given by org-gcal-down-days and org-gcal-up-days are fetched.

Customizing the contents of event entries

If you would like to customize the contents of event entries (for example, to add a property from the Google Calendar API that’s not automatically written to the Org-mode entry), you can add a function to the list org-gcal-after-update-entry-functions. For example, here is some code to add the Effort property to an entry based on the duration of the event (note that the current point is placed at the beginning of the entry when the function is called):

(defun my-org-gcal-set-effort (_calendar-id event _update-mode)
  "Set Effort property based on EVENT if not already set."
  (when-let* ((stime (plist-get (plist-get event :start)
                           :dateTime))
              (etime (plist-get (plist-get event :end)
                                :dateTime))
              (diff (float-time
                     (time-subtract (org-gcal--parse-calendar-time-string etime)
                                    (org-gcal--parse-calendar-time-string stime))))
              (minutes (floor (/ diff 60))))
    (let ((effort (org-entry-get (point) org-effort-property)))
      (unless effort
        (message "need to set effort - minutes %S" minutes)
        (org-entry-put (point)
                       org-effort-property
                       (apply #'format "%d:%02d" (cl-floor minutes 60)))))))
(add-hook 'org-gcal-after-update-entry-functions #'my-org-gcal-set-effort)

Troubleshooting

Debugging

Because we used the deferred.el to perform asynchronous operations like calling request (via ~request-deferred~), normal Emacs debugging and stack traces tend not to be as useful as usual. The best way to debug is to run M-x org-gcal-toggle-debug, which sets a variety of debugging variables to ease debugging. The old values of the variables are saved so they can be restored by another call to M-x org-gcal-toggle-debug.

One of the most useful things this enables is logging of HTTP requests. Open the *request-log* buffer to see all requests issued by this library.

Errors

Duplicate ID

You get an error like this:

Duplicate ID "FOO", also in file BAR

Most likely, this means some calendar events were mistakenly retrieved twice (for example, if you ran org-gcal-fetch on different computers). Search your Org-mode files for the duplicate ID “FOO” and delete one of the headlines with duplicate IDs (or just change the ID property on one of the events to something else).

Similar applications

dengste/org-caldav

org-gcal.el's People

Contributors

aaronjensen avatar alanconway avatar andre0991 avatar brettwitty avatar cashpw avatar cbmarc avatar cwsteinbach avatar danlamanna avatar erikmd avatar glennular avatar ifitzpat avatar itf avatar jx1e avatar kenbeese avatar kidd avatar mattdeboard avatar mhayashi1120 avatar mm-- avatar myuhe avatar nixmaniack avatar rhaps0dy avatar rollacaster avatar sachac avatar sje30 avatar syohex avatar t-suwa avatar tarsius avatar telotortium avatar tendant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

org-gcal.el's Issues

Gcal shouldn't remove tags and states in the headlines

Hi.

To be more compatible with the other org files in the agenda, Gcal should preserve any tag or state assigned after the sync. Those elements should be propagated to Google Calendar even if they don't mean anything.

Thanks for your help!

Update README to make new functionality from #34 more visible

At #34 (comment) it was remarked "This is an awesome feature but completely missing from the readme. Can we add some mention of it at least and link to this discussion? This is eactly what I was searching for and only found it accidentally."

Update the README to make it more obvious that org-gcal.el has been changed by #34. In general, it would be good to make the README better in general.

This project appears to be out of date with respect to google's oauth/calendar requirements

I tried to follow the instructions today to setup org-gcal, but google's workflow for oauth seems to be more stringent than when this project was initially set up. Google now requires that the use of the calendar API setup an OAuth consent screen, hosted on a trusted domain. Unless I'm misreading the org-gcal documentation this requirement and screen aren't covered in those docs.

What I expect: A clear explanation of how to setup the OAuth consent screen for org-gcal

Lisp nesting exceeded while fetching

I'm using a pre-release of Emacs 27 and the latest version of this package from MELPA, recently installed it 2 days ago and did the initial fetch of events successfully. I was trying to fetch events again so I could populate the near future for some planning and I got this error:

[error] request--callback: peculiar error: 401
[error] request-default-error-callback: https://www.googleapis.com/calendar/v3/calendars/[email protected]/events error
OAuth token expired. Now trying to refresh-token
Received HTTP 401
OAuth token expired. Now trying to refresh-token
You can run the command ‘org-gcal-fetch’ with M-x o-fet RET
Received HTTP 401
OAuth token expired. Now trying to refresh-token
deferred error : (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
Quit

Then I called org-gcal-request-token and pasted the token again. It did not work and complained again with:

deferred error : (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")

Any ideas of what I can try? I was already planning to see if there was a newer pre-release to upgrade to it, so I could try that.

Do not use ID property

The ID property is special in org mode (see org-id-get and friends). When posting an event with an existing ID, a duplicate is inserted:

:calendar-id: [email protected]
:ETag:     "3195851531422000"
:ID:       0adsj51cvclf76nqilsf9mtak4/[email protected]  <- added by gcal
:ID: d89e512b-e289-46b9-ac78-bc7ea2b7269a

We should either respect the original ID or use a different property, for example GCAL_ID.

Initial properties are not properly handled, resulting in local duplicate events

If I add an event such as this one:

* Test Event 1
  :PROPERTIES:
  :LOCATION: Location 1
  :END:
  <2018-12-06 Thu>

after using either org-gcal-post-at-point or org-gcal-sync, the result is as follows:

* Test Event 1
  :PROPERTIES:
  :LOCATION: Location 1
  :LINK: [[https://www.google.com/calendar/event?eid=xxx][Go to gcal web page]]
  :ID: xxx
  :END:

  <2018-12-06 Thu>

  :PROPERTIES:
  :LOCATION: Location 1
  :END:
  <2018-12-06 Thu>

If, on the other hand, I drop the properties altogether from the entry as follows:

* Test Event 2
  <2018-12-06 Thu>

and then run org-gcal-sync, I get the following:

* Test Event 2
  :PROPERTIES:
  :LINK: [[https://www.google.com/calendar/event?eid=xxx][Go to gcal web page]]
  :ID: xxx
  :END:

  <2018-12-06 Thu>

The Test Event 1 case leaves duplicate events in the local org file (as you can see from the above) but not in the Google calendar. Nevertheless, it is still quite a nuisance. One workaround, that works in the case of Test Event 1, is to just delete the trailing properties and timestamp and re-sync. Another workaround, that works in the case of Test Event 2 is to just add the :LOCATION: property to the updated event after the sync, once the :ID: and :LINK: properties have been added, then re-sync.

Note that I am using the google-calendar-layer (or at least my own working fork of it), as well as multiple calendars. I would gladly dig into this a bit further myself, but I'm afraid my E-Lisp skills are not quite up to the challenge, currently.

401 error when doing org-gcal-sync

Whenever I try org-gcal-sync I get:

REQUEST [error] Error (error) while connecting to https://www.googleapis.com/calendar/v3/calendars/l47bjiwa0oqfhdtrig41t68i1g/events. OAuth token expired. Now trying to refresh-token REQUEST [error] Error (error) while connecting to https://www.googleapis.com/oauth2/v3/token. deferred error : (error "Got error 401: (error http 401)")

I don't know what is causing this, but I have verified that I have set the client ID and client secret correctly. I'm not sure that I'm setting the calendar ID in org-gcal-file-alist correctly, but I've tried the ID code with and without the "@group.calendar.google.com" at the end, and it doesn't work either way.

Suggestion: Don't store gcal creds in init.el file

Hello. First off, this is great, thank you for picking up from the original repo from myuhe!

I push my init.el to github, and others do as well. Storing creds in a publicly committed file is bad security, so I wrote a small function that reads from an (uncommitted) gcal-secret.json file, and use that instead. Snippet:

;; Storing my creds in a secret file so I don't commit them here.
(require 'json)
(defun get-gcal-config-value (key)
  "Return the value of the json file gcal_secret for key"
  (cdr (assoc key (json-read-file "~/.emacs.d/gcal-secret.json")))
  )

(setq org-gcal-client-id (get-gcal-config-value 'org-gcal-client-id)
      org-gcal-client-secret (get-gcal-config-value 'org-gcal-client-secret)
      org-gcal-file-alist '(("[email protected]" . "~/Dropbox/org/schedule.org")))

If you'd like, I can make a PR to the README to suggest that other users do the same. If not, feel free to close this PR.

Cheers! jz

Pull no push

Hi,
I have followed the instructions to the letter and I am able to pull the calendar in google. However I am not able to push to this calendar. I receive no errors yet any schedule event in local agenda is not updated in the buffer. Are there any standard debug steps I can follow?

Events fetched into
~/orgfiles/gcal.org
Completed event fetching .
Events fetched into
~/orgfiles/gcal.org

post-at-point fails however with error 404.

The readme states to put the app as other however this is not available on the dashboard, desktop app is used instead. Both api for caldev as well as Calendar are active and show activity.

Maximum number of fetched events

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.

Org-gcal error: Couldn’t parse myfile.org

I've followed the installation instructions and it seems to work.

I can sync flawlessfully this file (M-x org-gcal-sync):

* one
* another
SCHEDULED: <2020-07-15 wed 09:15>
:PROPERTIES:
:calendar-id: [email protected]
:ETag:     "7777777777980000"
:ID:       xxxxxxxxxxa4jlcj0v998f4u18/[email protected]
:END:
:org-gcal:
:END:

But this one fails:

* another
SCHEDULED: <2020-07-15 wed 09:15>
:PROPERTIES:
:calendar-id: [email protected]
:ETag:     "7777777777980000"
:ID:       xxxxxxxxxxa4jlcj0v998f4u18/[email protected]
:END:
:org-gcal:
:END:
* one

showing the message in the title.

Run org-gcal-fetch every 30 minutes/hour. Is the best way (run-with-timer)? Will it lock up emacs?

I wanted to run org-gcal-fetch every hour to update the calendar. Currently, it locks up my agenda for a couple seconds or more whenever I access it or refresh it if using org-gcal-fetch in an org-agenda-mode-hook.

I was wondering is the best way to run this in a run-with-timer and if so will it lock up my emacs every time it is run? Also, will it throw a bunch of errors if I am not connected to the internet.

Or any better suggestions just seeing how other people have it setup?

org file automatically re-arrange when using org-gcal-post-at-point

Hi,

I have a .org file where I save all my events. This file is syncing with my google account. It works fine, but sometimes when I execute the org-gcal-post-at-point command my .org file automatically re-arrange all my events, and I have to arrange all of them manually once again.

The message that appears is:
OAuth token expired. Now trying to refresh-token

Write regression tests

Something like this can be used:

(require 'f)
(require 'el-mock)

(ert-deftest org-gcal-sync-test ()
  (with-stub
    (stub request-deferred
          => (deferred:succeed
               (make-request-response
                :symbol-status 'success
                :status-code 200
                :data (f-read-bytes "testing/successful-request")
                :-raw-header "Content-Type: application/json\n"
                )))
    (org-gcal-sync)
    ;; …assertions will go here…
    ))

Is Google Api online?

Dear all,
I have two different Windows machines running spacemacs with org-gcal. Since some days ago org-gcal-syn is not working anymore.

EDIT:
Turns out irt was just a matter of updating request.el

Use nextPageToken in org-gcal-sync to fetch all events matching search

The Events.list API says in the documentation for maxResults:

Maximum number of events returned on one result page. The number of events in the resulting page may be less than this value, or none at all, even if there are more events matching the query. Incomplete pages can be detected by a non-empty nextPageToken field in the response. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.

It's possible to increase the page size. However, it would probably be better to support using the nextPageToken to retrieve events by pages, especially because there's no guarantee that you'll retrieve maxResults events in a given list call (see above). This should be straightforward, but org-gcal-sync will have to be refactored a bit (after #42 is merged) to pass nextPageToken around while maintaining asynchrony.

This has a previous bug filed in #23

403 errors

I've recently started seeing several 403s while syncing:

org-gcal-sync: error: (error Got error 403: (error http 403))
Mark set
REQUEST [error] Error (error) while connecting to https://www.googleapis.com/calendar/v3/calendars/email/events/eventid
(error http 403)

If it helps, I have two calendars syncing. One for my primary email (for which the token is) and one for my secondary, which shares the calendar with my primary email completely.

Deleting events from the web does not work

Hi,

I followed the instructions and setup org-gcal. I am able to create events from my google calendar website and sync and changes to them from emacs. However, when I delete any event from the web interface, it still shows up in my org file.

What is the recommended way to delete events?

Thanks,
Tapan

Make gcal work without projects

Hi
I have a work google account and it seems I can't freely create google projects, since those are shared with my coworkers and link it with a billing account.
Is there a way to use org-gcal without the project?

Read and respect timezone

In org-gcal-sync, the timezone of the calendar, accessible via (plist-get data :timeZone), is not read. This results in wrong times being imported (and probably exported).

Additionally, times specified with inline timezones (2019-09-20T09:30:00+01:00 or 2019-10-05T13:30:00Z) are not treated correctly.

Feature request: show hangouts/meet call link.

image
Right now, org-gcal does not fetch the meeting conference room link (meet/hangouts). This would be super useful in my workflow. Is it difficult to add? I may consider contributing some day soon but would rather listen to your opinion about this.

Can't push to calendar

Running the version on Melpa (20190902.252) I can run the sync and fetch operations, but I can no longer add calendar entries. I tried to add something simple like this to test:

* testing melpa
SCHEDULED: <2019-09-14 Sat 13:45>

But it always fails. I've tried adding from the file in org-gcal-file-alist and from a general Org file, always the same issue. I turned on toggle-debug-on-error and this is the only output I get:

REQUEST [error] Error (error) while connecting to https://www.googleapis.com/calendar/v3/calendars/nil/events.
(error http 404)

deferred error : (error "Got error 404: (error http 404)")

If I revert to the myuhe version things work as expected.

Separate dev and master branches

Thanks to telotortium for taking over this package.

In addressing another issue, I upgraded from 3874040 (April 2019) and things imploded somewhat. I set about fixing whatever niggling errors cropped up (e.g., setting tobj to its old value when lacking a SCHEDULED property, fixing an erroneous find-and-replace of "status-code" to "status", checking fboundp of org-edit-headline which is only defined after org 8.3 despite 8.2.4 being the professed minimum requirement), but there were just too many.

I would like to know if teletortium can make a separate dev branch with the latest changes, and perhaps restore master to something I can work with (emacs 25.1). Thanks.

Error with org-gcal-post-at-point : Wrong type argument: number-or-marker-p, nil

Hello @kidd ,

First of all , great package , it's a godsend!!! , thanks also @myuhe

keep up the good work!

Can you please help me or give me some light on where to look for a solution.

I'm getting the following error when trying the function org-gcal-post-at-point

error in process sentinel: Wrong type argument: number-or-marker-p, nil [2 times]

The following is the file i'm trying to sync:

* Cumple Christiam
  :PROPERTIES:
  :END:
  <2018-08-05 dom.>

and this is my config file:

(setq package-check-signature nil)
(require 'org-gcal)
 :ensure t
 :config
(setq org-gcal-client-id "#Private.apps.googleusercontent.com"
	org-gcal-client-secret "#Private"
	org-gcal-file-alist '(("#[email protected]" .  "D://Documents//org-mode//gcal.org")))

(add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))
(add-hook 'org-capture-after-finalize-hook (lambda () (org-gcal-sync) ))
(add-hook 'post-command-hook 'cw/org-auto-toggle-fragment-display t )

I'm using emacs in a Windows10 Machine

Muchas Gracias de Antemano!

"deferred error : (wrong-type-argument stringp nil)" when finishing org-capture

Hi,
After running org-capture with the following template

    (setq org-capture-templates
      '(("a" "Appointment" entry (file  "~/org/cal.org" )
	 "* %?\n :PROPERTIES:\n :calendar-id: [email protected]\n :END:\n:org-gcal:\n%^T--%^T\n:END:\n")))

and finishing the capture with C-c I get deferred error : (wrong-type-argument stringp nil). I'd expected org-gcal-post-at-point to run correctly upon org-capture-before-finalize-hook but it seems like this is not working correctly. However, I can run M-x org-gcal-post-at-point inside the capture buffer before finalizing and it will work just fine.

Example org-capture input:

* Example
 :PROPERTIES:
 :calendar-id: [email protected]
 :END:
:org-gcal:
<2020-01-15 Wed 20:26>--<2020-01-15 Wed 20:26>
:END:

deferred error : (invalid-function (listp x))

My (outdated) version of org-gcal stopped working today with 400 errors, so I upgraded to 20200609.1915 and also updated all other packages. When running org-gcal-fetch I get the error

deferred error : (invalid-function (listp x))

with the following details:

Debugger entered--Lisp error: "deferred error : (invalid-function (listp x))"
  message("deferred error : %S" (invalid-function (listp x)))
  deferred:exec-task(#s(deferred :callback #f(compiled-function (x) #<bytecode 0x485b9d>) :errorback deferred:default-errorback :cancel #f(compiled-function (x) #<bytecode 0x15e8e25>) :next nil :status nil :value nil) ok nil)
  deferred:worker()
  apply(deferred:worker nil)
  timer-event-handler([t 24305 37693 928132 nil deferred:worker nil nil 401000])
  read-event(nil t 2)
  sit-for(2)
  execute-extended-command(nil "org-gcal-fetch" "org-gcal-fee")
  funcall-interactively(execute-extended-command nil "org-gcal-fetch" "org-gcal-fee")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

The deferred version is 20170901.1330, Emacs is 26.3. The local calendar org file is not updated due to this error.

Error with org-gcal-token file : Not make

Hello @kidd ,
Thanks for the package, also thanks @myuhe.
I have a problem about making org-gcal-token file. I use emacs in Windows 10. In org-mode when try to configure org-gcal, after C-c a a code Google page open and I can get success code. When I enter the code I get an error which is below;


Make c:/Users/dexta/AppData/Roaming/.emacs.d/org-gcal/.org-gcal-token

Got error: (error . "exited abnormally with code 2")

Got error: (error . "exited abnormally with code 2")

Could not contact remote service. Please check your network connectivity.

Press key for agenda command:

issues pushing entries to google calendar

Hello,
my setup is absolutely OK insofar as fetching entries from google is concerned. I have problem pushing, tho - I'm not entirely sure if that's because I fail to understand what exactly to do or due to some bug.

with something like that:

* testing local
<2020-05-09 Sat 10:00-11:00>

after org-gcal-post-at-point I get Wrong type argument: fixnump, nil

with this

* testing local
:org-gcal:
<2020-05-09 Sat 10:00-11:00>
:END:

I get this error

(error http 404)

Status code: 404
(error http 404)

deferred error : (error "Got error 404: (error http 404)")
user-error: Minibuffer window is not active

with something like that

* testing local
:PROPERTIES:
:ETag:     ""
:calendar-id: MY_CAL_ID
:ID:       MY_ID
:END:
:org-gcal:
<2020-05-09 Sat 10:00-11:00>
:END:

I get

ETag stale - will overwrite this entry with event from server.
Received HTTP 412
ETag stale - will overwrite this entry with event from server.

and then the entire entry is in my file is swapped another one that already exists in google cal.

This does not seem to be the intended behaviour to me.

Thanks in advance for the help

error fetching non-ascii characters

when google calendar is configured in spanish, whenever an accent is present it's not fetched as utf-8

ie-> saturday/sábado

:org-gcal:
<2020-08-08 s\341 . 13:00-14:00>
:END:

emacs asking for coding system

Anotación 2020-07-01 223723

MELPA

  • Primary goal for the project

Attain MELPA reference to this github repo instead of myuhe's abandoned one.

Cannot push calendar events with org-id

If an entry already has an org-id, then it cannot be pushed to the google calendar. A 404 is returned instead. I think this is because org-gcal is trying to use the org-id to locate the event in google calendar.

With an example event;

* TestPersonal                                                  :CAL:                                    
  SCHEDULED: <2019-12-18 Wed 08:00-09:00>                                                                
  :PROPERTIES:                                                                                           
  :ID:       bf928034-9dac-463b-a038-a6f988480269                                                        
  :calendar-id: <my-calendar-id>@group.calendar.google.com                                  
  :END:

org-gcal-post-at-point returns 404. If the :ID: property is removed, then everything works as expected.

Could the gcal ID property be renamed (e.g. GID?). This might fix the issue.

Org-gcal capture templates and duplicate events with org-gcal-sync hooks

Was asked to create an issue based on a question from this reddit thread - apologies to @telotortium who was very helpful in the thread.

I've tried to use your template format:

(setq org-capture-templates 
    `(("a" "Appointment" entry (file ,(concat org-directory "/gcal.org")) 
    "* %?\n:PROPERTIES:\n:calendar-id:\[email protected]
    \n:END:\n:org-gcal:\n%^T--%^T\n:END:\n\n" :jump-to-captured t))) 

(added whitespace to fit on screen)

and it doesn't fix my problem of duplicate events, and I'm still getting deferred error : (wrong-type-argument stringp nil) after capture.

I am a bit confused about the :jump-to-captured t option. With your above template, the following happens after I press Ctrl-c c and then a for Appointment:

  • I am prompted for the start date and time of my event, and then press RET

  • I am prompted for the end date and time of my event (this is fine, even useful for variable event lengths) and then press RET

  • I am prompted for the name of my event, which I type out.

  • I hit Ctrl-c Ctrl-c to capture the event

  • I am taken to gcal.org, where the event info is recorded with the name as the heading. At the same time, the error deferred error : (wrong-type-argument stringp nil) appears in the minibuffer.

As I understand it, you are suggesting that I run org-gcal-post-at-point on this heading. I do this, and I get the message about the evvent being posted. I save gcal.org.

Now I do M-x org-agenda and see my weekly agenda. As I do this, two things happen simultaneously:

  • The new event shows up in my agenda

  • I can see that gcal.org is now repopulated with a duplicate of my event, with the same time info but different ETag and ID in the :Properties: drawer.

I refresh my calendar, and I now have two copies of the event in my agenda.

So this is (minus the time entry setup in the capture template) essentially the same scenario I was in before. What seems to be happening is that the event is synced from the org-file to the calendar, and then running org-agenda pulls the same event from the calendar, where it has a different ID stamp, and this altered copy stored in gcal.org is treated as a second event.

Is it possible that the issue is in how my org-gcal setting is configured earlier in my init file? This is what I have below, maybe the hooks are now unnecessary?:

(use-package org-gcal
:ensure t
:config
(setq org-gcal-client-id "random_stuff.apps.googleusercontent.com"
org-gcal-client-secret "random_stuff"
org-gcal-file-alist '(("[email protected]" .  "~/Org/gcal.org"))))

(add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))
(add-hook 'org-save-all-org-buffers (lambda () (org-gcal-sync) ))

wrong-type-argument hash-table-p nil

I configured my org-gcal according to the instructions in README.org, however when I run org-gcal-fetch, only one event get pulled from my calendar into the my org file and I get the error
(wrong-type-argument hash-table-p nil)

If I redo org-gcal-fetch I get
org-gcal--archive-old-event: Org-gcal error: Couldn’t parse /schedule.org

and I have to delete the file before doing org-gcal-fetch which repeats the first error.

I am testing with a calendar containing a single event. This is schedule.org after running org-gcal-fetch and getting the error


* Test
:PROPERTIES:
:ETag:     "3179332857274000"
:calendar-id: REDACTED
:ID:       REDACTED
:END:

Migrate to using auth-source for holding credentials

Currently the various credentials needed by org-gcal are stored in org-gcal-token-plist, which is serialized to org-gcal-token-file. However, there are several disadvantages to this format:

  • Only supports one OAuth client_id/client_secret, which means it's impossible to use org-gcal with more than one account.
  • Credentials on disk are unencrypted.

Instead, move to the auth-source library, which can handle both of these cases.

Events are not removed if a recurrence is deleted

I don't know the exact repro, but I had a recurrence that went into the future (meeting every workday). That recurrence was removed from google calendar, but they never disappeared from org-gcal.

I believe this happened before the sync tokens were implemented, and it's still happening. I have to purge my output org files and clear sync tokens before refreshing to guarantee I only have current events visible.

Problem with coding-system

I get this error-message when syncing with org-gcal:

These default coding systems were tried to encode text
in the buffer ‘ *temp file*’:
  (utf-8 (127 . 4194243) (128 . 4194212))
However, each of them encountered characters it couldn’t encode:
  utf-8 cannot encode these: � �

Click on a character (or switch to this window by ‘M-x other-window’
and select the characters by RET) to jump to the place it appears,
where ‘C-u C-x =’ will give information about it.

Select one of the safe coding systems listed below,
or cancel the writing with C-g and edit the buffer
   to remove or modify the problematic characters,
or specify any other coding system (and risk losing
   the problematic characters).

  raw-text no-conversion

with this in a temp-buffer:

{"start":{"dateTime":"2019-05-21T05:00:00Z","date":null},"end":{"dateTime":"2019-05-21T05:10:00Z","date":null},"summary":"Sophämtning","location":null,"description":null}

Add a picture that shows this since the text gets encoded in Github.

This worked before the summer and I don't know what exactly changed between the working and non working versions.

Apparently it is the characters å,ä,ö that don't get converted correctly.

If I clean out my gcal.org-file and do a fresh synchronization, it works. But if I synchronize directly after that I get the error message above. I read somewhere that it might be related to double encoding, but I dont know if this is the issue here.

Versions:

  • Emacs: GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-08-15
  • Org-gcal: 20190812.951
  • Org: Org mode version 9.2.5 (9.2.5-1-gff6508-elpa @ *home/sdaa*.emacs.d/elpa/org-20190812/)

See also: StackExchange
2019-08-16 (1)_LI

Duplicated item when created with a template.

Hi i have a template to create Google Appointment in emacs.

*** Google Appointment
#+BEGIN_SRC emacs-lisp
(after! org (add-to-list 'org-capture-templates
             '("a" "Appointment" entry (file  "~/.org/gcal.org" )
"* %?
:PROPERTIES:
:ETag:
:calendar-id: [email protected]
:ID:
:END:
:org-gcal:\n%^T
:END:")))
#+END_SRC

But when i create an appointment it gets duplicated.
The appointment created with template

* Test for GitHub
:PROPERTIES:
:ETag:
:calendar-id: [email protected]
:ID:
:END:
:org-gcal:
<2020-04-13 Mon 13:26>
:END:

Duplicated one created just after C-c C-c

* Test for GitHub
:PROPERTIES:
:ETag:     "3173201679274000"
:calendar-id: [email protected]
:ID:       chgr74g0kuhlb80urpk3qutmhc/[email protected]
:END:
:org-gcal:
<2020-04-13 Mon 13:26>
:END:

Make `org-gcal-post-at-point` do something useful when a headline has no org-gcal properties

Currently, calling org-gcal-post-at-point on an entry with no org-gcal drawer or calendar-id property will throw an error. We should do something useful by default instead. Here's what I propose:

  • calendar-id property: select from calendar IDs in org-gcal-file-alist, defaulting to the most recently selected one (I think there's a built-in Emacs function that will do this).
  • Event start time: Take the start time from the SCHEDULED property, or the first active timestamp, on the headline, or else suggest the current time.
  • Event end time: Take the end time from the active timestamp used for the start time, if present, else take it from the Effort property (minus already clocked time), else a default duration.
  • Event ID: use existing ID if present, else the ID generated by the Calendar API (this is already implemented).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.