gcalcli
gcalcli copied to clipboard
Display Google Tasks
One concern is that already-logged-in users will have to clear their auth cache and re-auth when upgrading, or else it'll fail with permission errors while trying to access self.tasks_service
Closes #337 Closes #558 Closes #221
Note: this PR does not attempt to provide full Tasks integration (ie the ability to add or edit tasks), only the displaying of it. I may attempt this in another PR though.
It seems like I can't mark the pull request as a draft
I get the following when trying to request the Tasks API (while authenticated):
HttpError 403 when requesting https://tasks.googleapis.com/tasks/v1/users/@me/lists?alt=json returned "Tasks API has not been used in project 905806700719 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/tasks.googleapis.com/overview?project=905806700719 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.". Details: "Tasks API has not been used in project 905806700719 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/tasks.googleapis.com/overview?project=905806700719 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
@insanum, you might want to enable tasks v1 in your API Console
I can start developing without it, but it'll be more difficult. I'll start anyways
I enabled the Tasks API to the gcalcli Google project. Let me know if you run into issues.
Ah, it still says that it's not enabled. I tried deleting ~/.gcalcli_oauth
and ~/.gcalcli_cache
, without success. Can you tell me what version of the Google Tasks API you enabled, so that I can choose the correct one? (In case there's something more recent than v1)
Here's the stdout just in case:
/home/ewen/.cache/pypoetry/virtualenvs/gcalcli-xBV0FQLW-py3.9/lib/python3.9/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /home/ewen/.gcalcli_oauth: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
Ouverture dans une session de navigateur existante.
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/v2/auth?client_id=905806700719-t5vnoihjo24n4jogi0p64mdijm5h181c.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ftasks&access_type=offline&response_type=code
If your browser is on a different machine then exit and re-run this
application with the command-line parameter
--noauth_local_webserver
Authentication successful.
Traceback (most recent call last):
File "/home/ewen/.cache/pypoetry/virtualenvs/gcalcli-xBV0FQLW-py3.9/bin/gcalcli", line 5, in <module>
main()
File "/home/ewen/projects/gcalcli/gcalcli/cli.py", line 152, in main
gcal.AgendaQuery(start=parsed_args.start, end=parsed_args.end)
File "/home/ewen/projects/gcalcli/gcalcli/gcal.py", line 1267, in AgendaQuery
return self._display_queried_events(start, end)
File "/home/ewen/projects/gcalcli/gcalcli/gcal.py", line 1212, in _display_queried_events
tasks_list = self._search_for_tasks(start, end, search)
File "/home/ewen/projects/gcalcli/gcalcli/gcal.py", line 1171, in _search_for_tasks
for tasklist in self.tasks_service.tasklists().list().execute():
File "/home/ewen/.cache/pypoetry/virtualenvs/gcalcli-xBV0FQLW-py3.9/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/ewen/.cache/pypoetry/virtualenvs/gcalcli-xBV0FQLW-py3.9/lib/python3.9/site-packages/googleapiclient/http.py", line 915, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://tasks.googleapis.com/tasks/v1/users/@me/lists?alt=json returned "Tasks API has not been used in project 905806700719 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/tasks.googleapis.com/overview?project=905806700719 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.". Details: "Tasks API has not been used in project 905806700719 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/tasks.googleapis.com/overview?project=905806700719 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">
I'm not going to claim to understand the whole Google Cloud API management as it's presented today (vs when gcalcli was started many years ago). :-)
Here is what I see on the console. One thing I noticed in your error message is the project number 9058xxx... isn't the same project number. Did you create your own project for calendar API access?
hm... All I did was add a service via build
:
self.tasks_service = build(
serviceName="tasks", version="v1", http=self._google_auth()
)
using self._google_auth()
.
Maybe I shouldn't be calling _google_auth
again but re-use the returned object in both build
calls? I'll try that and see how it goes.
Still no success, it gives the same error message and refers to project 905806700719
Even weirder, the web auth flow still displays gcalcli as the application name, as if it was the correct project
It seems like it indeed created a new 'gcalcli' project on my own google account automatically (which bizarre in and of itself) without me changing anything in the __API_CLIENT_*__
constants. I was able to activate the Google Tasks API by myself, and will develop with that setup. I just hope that it correctly uses your project instead of mine when this PR gets merged, but I guess that we'll have to wait & see...
So i'm not too sure about how to integrate it into the gigantic GoogleCalendarInterface
-- should I make something separate?
Also, for the --tsv
output, since tasks have different data from events, should we add an option to only output events or tasks? Should a new column be added to indicate whether the line describes a task or an event?
I didn't have much time lastly to work on this PR, but I'm motivated to get it done by May
I don't have an opinion one way or the other. Only thing I suggest is do whatever feels right and makes the most sense.
@michaelmhoffman I saw your PR w/ the huge refactoring of _tsv()
. How should I go about integrating Tasks with those new Handler
classes?
EDIT: To clarify, would adding a type
field that is either event
or task
be useful? And how should I got about implementing that?
Out of curiosity, how close are you to getting this completed?
@rudrrayan still waiting for @michaelmhoffman to answer my question. I don't really want to mess up the project's architecture, since it's quite large.
@ewen-lbh I'm not familiar with the Google Tasks API (or even Tasks as an end-user at all) unfortunately. Skimming the API it does not seem like there is a lot of overlap between the fields of an event and a task. The general pattern might be useful for you. Will discuss that below.
Would it make sense to have a separate entry points for working with tasks? I don't use tasks myself but feel they are rather orthogonal to calendar events and am not sure I would want gcalcli agenda
to start listing tasks as well as events? A couple of alternatives would be:
- Creating a top-level
gtaskcli
command and then you could implement whichever subcommands make sense - Creating a subcommand for viewing tasks (
gcalcli tasks
)
Doing this will also keep the tasks code relatively self-contained which will make it easier for people to edit it without stepping on the toes of people working on events and vice versa. And if that's the case I don't think many will care much how you implement it.
If you would like to use something like details.Handler
in your implementation, my suggestion is to duplicate the file making a task_details.py
, and then change things so that they fit the task interface.