New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use oauth2 lib and remove deferred dependency #14

Open
wants to merge 16 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@kidd
Owner

kidd commented Jul 22, 2018

Use oauth2 library instead of manual managing of tokens. http calls
are done through it so we don't use deferred.el anymore.

kidd added some commits Jul 22, 2018

use oauth2 lib and remove deferred dependency
Use oauth2 library instead of manual managing of tokens. http calls
are done through it so we don't use deferred.el anymore.
@telotortium

This comment has been minimized.

Show comment
Hide comment
@telotortium

telotortium Jul 22, 2018

It's probably worth noting somewhere that oauth2 uses plstore, and thus you now need to install gpg (or else configure plstore somehow).

telotortium commented Jul 22, 2018

It's probably worth noting somewhere that oauth2 uses plstore, and thus you now need to install gpg (or else configure plstore somehow).

Show outdated Hide outdated org-gcal.el

kidd added some commits Jul 22, 2018

add org-gcal--post-event-internal
Entrypoint to creating an event in a google calendar without relying
on current-file, location or anything
@telotortium

This comment has been minimized.

Show comment
Hide comment
@telotortium

telotortium Jul 22, 2018

I've been testing this out a little - it seems that this code doesn't refresh the token properly when the access token expires - I haven't investigated to figure out why yet. It's possible that you need to manually reauthorize whenever you receive a 401 from the Google Calendar API. See also https://developers.google.com/calendar/v3/errors.

telotortium commented Jul 22, 2018

I've been testing this out a little - it seems that this code doesn't refresh the token properly when the access token expires - I haven't investigated to figure out why yet. It's possible that you need to manually reauthorize whenever you receive a 401 from the Google Calendar API. See also https://developers.google.com/calendar/v3/errors.

@kidd

This comment has been minimized.

Show comment
Hide comment
@kidd

kidd Jul 22, 2018

Owner

yes, I'm working on that also. It looks like oauth2.el defadvice is not triggering.

Things I'm about to try are:

Owner

kidd commented Jul 22, 2018

yes, I'm working on that also. It looks like oauth2.el defadvice is not triggering.

Things I'm about to try are:

@kidd

This comment has been minimized.

Show comment
Hide comment
@kidd

kidd Jul 22, 2018

Owner

it looks like using oauth2-url-retrieve-synchronously fixes it, but it's not ideal.
apparently oauth--url-advice is not retained correctly in the async version. Still looking into it.

Owner

kidd commented Jul 22, 2018

it looks like using oauth2-url-retrieve-synchronously fixes it, but it's not ideal.
apparently oauth--url-advice is not retained correctly in the async version. Still looking into it.

@kidd

This comment has been minimized.

Show comment
Hide comment
@kidd

kidd Jul 23, 2018

Owner

from url-retrieve docstring:

The variables ‘url-request-data’, ‘url-request-method’ and
‘url-request-extra-headers’ can be dynamically bound around the
request; dynamic binding of other variables doesn’t necessarily
take effect.

And yes, the async version doesn't get any extra var than the ones defined in url-http method.

It's not easy to write a hack for this to work either.

I'll be looking for alternative ways to keep asynchronicity and code reuse (thinking of make-thread or async). Until we find something that works, this is on hold.

Owner

kidd commented Jul 23, 2018

from url-retrieve docstring:

The variables ‘url-request-data’, ‘url-request-method’ and
‘url-request-extra-headers’ can be dynamically bound around the
request; dynamic binding of other variables doesn’t necessarily
take effect.

And yes, the async version doesn't get any extra var than the ones defined in url-http method.

It's not easy to write a hack for this to work either.

I'll be looking for alternative ways to keep asynchronicity and code reuse (thinking of make-thread or async). Until we find something that works, this is on hold.

telotortium pushed a commit to telotortium/emacs.d that referenced this pull request Jul 23, 2018

Robert Irelan
Revert "Update to oauth2 branch on kidd/org-gcal.el"
On kidd/org-gcal.el#14, some difficulties have been
encountered with the oauth2 branch, and refresh tokens don't work properly on
this branch, so I'm reverting back to the rebind branch for now.

kidd added some commits Jul 24, 2018

Fix asynconicity with threads
oauth automatic token-refreshing does not work with asynconous
url-retrieve.  That happens because dynamic bindings are not held
through the request (except a few chosen ones `url-http').

This commit comes over the synchronous + refresh problem by using
multiple threads in a synchronous way.
Show outdated Hide outdated org-gcal.el
@rprimus

This comment has been minimized.

Show comment
Hide comment
@rprimus

rprimus Jul 26, 2018

Thu Jul 26 18:03:24 BST 2018

Hi,

Will the move to oath2 stop events being written to .org-gcal-token whenever org-gcal-refresh-token is called?

Looking forward to this updated version being pushed to MELPA.

rprimus commented Jul 26, 2018

Thu Jul 26 18:03:24 BST 2018

Hi,

Will the move to oath2 stop events being written to .org-gcal-token whenever org-gcal-refresh-token is called?

Looking forward to this updated version being pushed to MELPA.

@rprimus

Thu Jul 26 18:10:34 BST 2018

In org-gcal-sync, optional arg silent has been removed, however, it is still mentioned in the DOCSTRING.

@kidd

This comment has been minimized.

Show comment
Hide comment
@kidd

kidd Jul 26, 2018

Owner

@rprimus , when using oauth2.el, tokens are stored using plstore.
There are some issues with this branch that still are not solved (#14 (comment) for more info).

Until we find a suitable solution of each of those, this branch won't be merged.

Owner

kidd commented Jul 26, 2018

@rprimus , when using oauth2.el, tokens are stored using plstore.
There are some issues with this branch that still are not solved (#14 (comment) for more info).

Until we find a suitable solution of each of those, this branch won't be merged.

reduce the number of times plstore asks for a password
Lifting the call to `org-gcal-auth' was a bad idea because when the
token expired, we were sending the expired token for each calendar we
want to synchronize. Now the first one that gets the expired token
asks for renewal, and next ones use the renewed token.
@bobberb

This comment has been minimized.

Show comment
Hide comment
@bobberb

bobberb Aug 9, 2018

When this is mature I would appreciate a buzz to test this branch on windows.

bobberb commented Aug 9, 2018

When this is mature I would appreciate a buzz to test this branch on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment