Sync Google Calendar With Org Agenda
I use org-mode an awful lot - it helps me manage my tasks and code all in one place. However, the organisation that I work for have just migrated over to Google Suite and manage meetings extensively using Google Calendar. I really wanted my Google Calendar to sync with my org-agenda. Org-agenda is a tool that pulls in any scheduled activities from all your files in to one dynamic view. It’s pretty much what drives my working day. Having meetings arranged with colleagues in my org-agenda will help me schedule my day.
The package org-gcal provides two way syncing with Google Calendar (and has other documentation).
This is how I did it.
Using elpa, I installed the package:
org-gcal package and install.
Create Api Credentials
Then, go to google and get credentials to access your calendar. You will need to go to the google developers portal where you may need to enable the developers’ api. You will need to find Api & Services and then click on credentials. You will create some OAuth 2.0 client IDs credentials - one being the API key and the other being a secret. Make a note of these, or download the JSON file that Google provides.
Enable these credentials for Google Calendar.
Then, the README for org-cal tells you to find the link for your calendar. This didn’t work for me. Instead, I found the link in the url in the address bar of my browser (click on the image to see more detail):
(require ‘org-gcal) (setq org-gcal-client-id “your-id-foo.apps.googleusercontent.com” org-gcal-client-secret “your-secret” org-gcal-file-alist ‘((“email@example.com” . “~/schedule.org”) (“firstname.lastname@example.org” . “~/task.org”)))
Copy that string in to your
~.emacs file, substituting the proper parts (your org-gcal-client-id and secret and the files that you wish to create when you sync).
Save the file and then execute
M-x load-file <RET>.emacs to reload this file.
Sync and org-agenda-file-to-front
Now you need to sync your calendar, which will create a new org file (as you specified in the settings.
Once that file is created open it
and thenM-x org-agenda-file-to-front`. This command will include the new file.
You can also create a hook to run
org-gcal-sync when you open your agenda by placing this snippet in your
(add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))