Skip to content

Commit

Permalink
Merge pull request #200 from telotortium/oauth2-auto
Browse files Browse the repository at this point in the history
Switch to oauth2-auto for Google Calendar OAuth2
  • Loading branch information
telotortium authored Nov 19, 2022
2 parents 40291be + 7bcb0ab commit 86faad2
Show file tree
Hide file tree
Showing 7 changed files with 699 additions and 205 deletions.
4 changes: 3 additions & 1 deletion Cask
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(source melpa)
(source gnu)

(package-file "org-gcal.el")
(package-descriptor "org-gcal-pkg.el")

(files :defaults)

(development
(depends-on "el-mock")
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
THIS_MAKEFILE_DIR = $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
EMACS ?= emacs
SRC=org-gcal.el org-generic-id.el
SRC=org-gcal.el org-generic-id.el oauth2-auto.el
TEST=test/org-gcal-test.el test/org-generic-id-test.el
BUILD_LOG = build.log
CASK ?= cask
PKG_DIR := $(shell $(CASK) package-directory)
ELCFILES = $(SRC:.el=.elc)
.DEFAULT_GOAL := all

.PHONY: all clean load-path compile test elpa
.PHONY: all clean load-path compile test elpa update-oauth2-auto

all: compile test

Expand All @@ -27,3 +27,8 @@ compile: $(SRC) elpa
test: $(SRC) $(TEST) elpa
$(CASK) exec ert-runner -L $(THIS_MAKEFILE_DIR) \
$(foreach test,$(TEST),$(addprefix $(THIS_MAKEFILE_DIR)/,$(test)))

# Vendor oauth2-auto from my fork until oauth2-auto is added to MELPA.
update-oauth2-auto:
curl -o oauth2-auto.el \
https://raw.githubusercontent.com/telotortium/emacs-oauth2-auto/main/oauth2-auto.el
27 changes: 17 additions & 10 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ screen that says "This app isn't verified". You will need to click on the
- [[https://github.com/tkf/emacs-request][tkf/emacs-request]]
- [[https://github.com/jwiegley/alert][jwiegley/alert]]
- [[https://elpa.gnu.org/packages/persist.html][~persist~]]
- [[https://github.com/skeeto/emacs-aio][skeeto/emacs-aio]]
- [[https://github.com/rhaps0dy/emacs-oauth2-auto][rhaps0dy/emacs-oauth2-auto]] (actually using vendored fork
[[https://github.com/telotortium/emacs-oauth2-auto/tree/main][telotortium/emacs-oauth2-auto]])

=org-gcal= is now available in the famous emacs package repo [[http://melpa.milkbox.net/][MELPA]], so the
recommended way is to install it through Emacs package management system.
Expand Down Expand Up @@ -92,19 +95,29 @@ on resolving this issue.
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-file-alist for
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

#+begin_src elisp
(require 'org-gcal)
(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)
#+end_src

*** 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:

#+begin_src elisp
(setq plstore-cache-passphrase-for-symmetric-encryption t)
#+end_src

** Multiple accounts
Expand Down Expand Up @@ -247,12 +260,12 @@ in any way.

** Commands
*** =org-gcal-fetch=
Fetch Google calendar events for all calendar IDs in =org-gcal-file-alist=
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-file-alist=. Does not update events on the server.
=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.
Expand All @@ -275,12 +288,6 @@ in any way.
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-request-token=
Request new OAuth access and refresh tokens. You should not need to call
this function in normal use, since it is called automatically on the first
run. However, you can call it again if for some reason the tokens stop
working. This should be rare - =org-gcal= will automatically refresh the
OAuth access token when it expires (every 3600 seconds).

** Deleting events

Expand Down
Loading

0 comments on commit 86faad2

Please sign in to comment.