wtf icon indicating copy to clipboard operation
wtf copied to clipboard

Setting up integration with Google calendar doesn't work

Open viq opened this issue 2 years ago • 4 comments

https://wtfutil.com/modules/google/gcal/ points to https://developers.google.com/calendar/api/quickstart/go which doesn't work with new go. Running https://developers.google.com/calendar/api/quickstart/python instead gives me two files: credentials.json and token.json.

Trying to use credentials.json results in

Get "https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&minAccessRole=writer&pageToken=&prettyPrint=false&showHidden=false": oauth2: cannot fetch token: 400 Bad Request
Response: {
  "error": "invalid_grant",
  "errors_description": "Token has been expired or revoked."
}

Trying to use token.json results in

oauth2/google: no credentials found

Trying to use file generated using jq -cs '.[0] * .[1]' credentials.json token.json > gcal.json (freshly after running pipenv run python quickstart.py and getting some calendar entries from it) results in same error as with credentials.json.

And I need to figure out periodically how to make it work again since https://github.com/wtfutil/wtf/issues/1077 is still a thing.

viq avatar Apr 28 '22 16:04 viq

idk if anyone is still struggling with this, but in case they are, i just had to do this as well, and just figured it out: quickstart.py indeed does generate 2 files, credentials.json and token.json. after generating those, set the secretFile value in wtf's config.yml to the path to credentials.json. so, in my case, it was

secretFile: "/Users/rblanchard/.config/wtf/gcal/credentials.json"

THEN, due to this hardcoded path in the gcal module you have to copy the contents of the token.json file to the root wtf directory, so in my case that was

/Users/rblanchard/.config/wtf/[email protected]

but since that was a manual process, im not sure whats gonna happen when the token expires, i assume i would have to do it again, which would be pretty annoying. i need to learn go anyway so i might try to pick this up to be more agnostic about the source of the token and/or add that as a config setting, as i remember the last time i tried to integrate gcal it was very painful (but in a different way), so im sure it will be annoying in a fun new way in the future as well

Rosswell avatar Aug 05 '22 23:08 Rosswell

Yeah, the whole auth flow is no longer going to be supported as is, so a bug chunk of this is going to have to be re-written. Trying to read up on some of these changes to get a better sense of next steps.

Seanstoppable avatar Aug 24 '22 02:08 Seanstoppable

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 20 '23 05:02 stale[bot]

I've just run into this issue. My assumption is that the workflow used is a Web Auth with callback to localhost, which is the "Out of Bounds" flow that Google said they deprecated in early 2023 but modded to use the still-supported web auth flow.

  1. I shall try tomorrow to set up a Service Account instead, see if the credentials generated with that do work in wtfutil and
  2. if the positive authorisation against the API persists past 7 days

As a workaround, it may be cool to display the error and the auth URL required to re-authenticate. This way, at least regular users don't have to go chasing the URL in source code.

EDIT1: Indeed, you can cat token.json | tee ../<yourmail>@@domain.com-gcal-auth.json

from your gcal directory after having run the quickstart.py. This opens the AuthURL with the required credentials from the manual and updates the token. I may write a bash script to automate this in the future.

jaltgen avatar Jan 27 '24 21:01 jaltgen