wtfutil / wtf

The personal information dashboard for your terminal
http://wtfutil.com
Mozilla Public License 2.0
15.83k stars 804 forks source link

[GCAL] Request and store refresh_token in gcal_auth.json #1077

Closed sreeram-dev closed 2 years ago

sreeram-dev commented 3 years ago

What's broken?

Response after completing the oauth2 redirection flow to get google calendar API access token for gcal integration.

HTTP/1.1 200 OK
Content-length: 299
X-xss-protection: 0
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Vary: Origin, X-Origin, Referer
Server: scaffolding on HTTPServer2
-content-encoding: gzip
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Sun, 11 Apr 2021 14:18:20 GMT
X-frame-options: SAMEORIGIN
Alt-svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Content-type: application/json; charset=utf-8

{
  "access_token": "<insert_token>", 
  "scope": "https://www.googleapis.com/auth/calendar.readonly", 
  "expires_in": 3434, 
  "token_type": "Bearer"
}

Without refresh token in gcal_auth.json, gcal module breaks after sometime. We need to periodically fetch and store the new access token using refresh token.

Workaround

I am presently using quickstart.py script to get refresh token and access token, and store it in gcal_auth.json.

senorprogrammer commented 3 years ago

This is interesting. I haven't had this problem and I've been using the gCal module since the beginning. I wonder if the expires_at is a new value, and my token has no expiry attached to it?

stale[bot] commented 2 years ago

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.

viq commented 2 years ago

This is still an issue. What's more interesting, the token.json as generated by quickstart.py does not work with wtfutil. I have the quickstart.py in ~/.config/wtf/gcal/, in my config file in gcal section I have

secretFile: "~/.config/wtf/gcal/token.json"

and after removing token.json, running quickstart.py, going through the OAuth dance, and running wtfutil I get

oauth2/google: no credentials found

Which is even more annoying when the token eventually expires and I have to figure out again how to make it work.