JulienMasson / org-gtasks

Org sync with Google Tasks
GNU General Public License v3.0
49 stars 15 forks source link

OAuth token expiry #18

Open carwin opened 2 years ago

carwin commented 2 years ago

Hi again @JulienMasson - I'm running into a new issue where my OAuth token has expired, but the refresh token process seems unable to complete.

Upon running org-gtasks and going through the menu options to select an account and task list, my **Messages** buffer is flooded with the following:

[error] request--callback: peculiar error: 401
[error] request-default-error-callback: https://www.googleapis.com/oauth2/v3/token error
OAuth token expired. refresh access token

This continues for some time until finally returning deferred:resignal: Variable binding depth exceeds max-specpdl-size, though I'm not sure if this last bit is related.

What's the process for wiping out any existing tokens and starting over fresh?

JulienMasson commented 2 years ago

Hi @carwin,

What's the process for wiping out any existing tokens and starting over fresh?

hummm (org-gtasks-check-token account) is responsible to check the token.

And this error:

[error] request--callback: peculiar error: 401 [error] request-default-error-callback: https://www.googleapis.com/oauth2/v3/token error OAuth token expired. refresh access token

should be catch in org-gtasks-parse-errors.

Do you a way to reproduce "easily" the issue ?

carwin commented 2 years ago

Unfortunately I don't. The issue seems rather intermittent, over the last 5 days I've encountered it only twice.

The only way I've successfully gotten around it has been to completely wipe out the user Emacs directory, which isn't ideal.

Another package, org-gcal, seems to have a function that might be worth copying to deal with this and other outdated/corrupt token issues: org-gcal-sync-tokens-clear, which clears all the API sync tokens. Something like that could help deal with this scenario when it does occur!

(defun org-gcal-sync-tokens-clear ()
  "Clear all Calendar API sync tokens.

  Use this to force retrieving all events in ‘org-gcal-sync’ or
  ‘org-gcal-fetch’."
  (interactive)
  (setq org-gcal--sync-tokens nil)
  (persist-save 'org-gcal--sync-tokens))