pimutils / pimutils/vdirsyncer
[Google Calendar] Stack trace when discovering for the first time
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 185
- Avg merge
- 11h 49m
- Merged PRs (30d)
- 1
Description
Hi there,
I recently acquired a new email address with Google workspace for the first time in a few years. I'm trying to setup synchronisation using oauth2 (I believe I'd made use of app passwords before).
With the following remote configuration:
[storage calendar_redacted_remote]
client_id = "<redacted>.apps.googleusercontent.com"
client_secret = "<redacted>"
token_file = "/home/john/.cache/redacted-access-tokens"
type = "google_calendar"
When I run vdirsyncer -vdebug discover, I receive a stacktrace:
john@mars:~/ > vdirsyncer -vdebug discover
Discovering collections for pair calendar_redacted
Opening https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=371803114843-1hggirbdliohotaeuqe41575n9af4di9.apps.googleusercontent.com&redirect_uri=http%3A%2F%2F127.0.0.1%3A56813&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar&state=z6DtYIiaMSREKva8q2tp8fqRAycK4x&access_type=offline&approval_prompt=force ... M
Follow the instructions on the page.
"GET /?state=z6DtYIiaMSREKva8q2tp8fqRAycK4x&code=4/0ASVgi3J4DYu9DESpaHEm9RbDAA6lNJJMUiNEqiCngYx7R15ygO6Hc7pm4vkwNYVxzFyzww&scope=https://www.googleapis.com/auth/calendar HTTP/1.1" 200 28
debug: server handled request!
debug: authorization_response: https://127.0.0.1:56813/?state=z6DtYIiaMSREKva8q2tp8fqRAycK4x&code=4/0ASVgi3J4DYu9DESpaHEm9RbDAA6lNJJMUiNEqiCngYx7R15ygO6Hc7pm4vkwNYVxzFyzww&scope=https://www.googleapis.com/auth/calendar
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/cli/discoverbug: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.py", line 265, in _print_collections = await self._discover()
debug: discovered = await get_discovered()
debug: ^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/cli/discover.py", line 178, in get_self
debug: self._discovered = await self._discover()
debug: ^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/cli/discover.py", line 187, in _discover
debug: return handle_storage_init_error(self._cls, self._config)
debug: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/cli/discover.py", line 183, in _discover
debug: discovered = await aiostream.stream.list(self._cls.discover(**self._config))
debug: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/zs5vdy5d77fmk757qc3v9x6v7qjvnn13-python3.12-aiostream-0.6.4/lib/python3.12/site-packages/aiostream/core.py", line 60, in wait_stream
debug: async for item in streamer:
debug: File "/nix/store/zs5vdy5d77fmk757qc3v9x6v7qjvnn13-python3.12-aiostream-0.6.4/lib/python3.12/site-packages/aiostream/stream/aggregate.py", line 89, in list
debug: async for item in streamer:
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/storage/dav.py", line 485, in discover
debug: async for collection in d.discover():
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/storage/dav.py", line 271, in discover
debug: for c in await self.find_collections():
debug: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/storage/dav.py", line 223, in find_collections
debug: rv = await aiostream.stream.list(self._find_collections_impl(""))
debug: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/zs5vdy5d77fmk757qc3v9x6v7qjvnn13-python3.12-aiostream-0.6.4/lib/python3.12/site-packages/aiostream/core.py", line 60, in wait_stream
debug: async for item in streamer:
debug: File "/nix/store/zs5vdy5d77fmk757qc3v9x6v7qjvnn13-python3.12-aiostream-0.6.4/lib/python3.12/site-packages/aiostream/stream/aggregate.py", line 89, in list
debug: async for item in streamer:
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/storage/dav.py", line 253, in _find_collections_impl
debug: r = await self.session.request(
debug: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/storage/google.py", line 68, in request
debug: await self._init_token()
debug: File "/nix/store/dmgi0wfaasf6k3x01shrvqfvbv0bl0bx-python3.12-vdirsyncer-0.19.3/lib/python3.12/site-packages/vdirsyncer/storage/google.py", line 154, in _init_token
debug: self._token = await session.fetch_token(
debug: ^^^^^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/n3b3gmqvwwzv16p6s6akrzjqhb2jlfyj-python3.12-aiohttp-oauthlib-0.1.0/lib/python3.12/site-packages/aiohttp_oauthlib.py", line 379, in fetch_token
debug: self._client.parse_request_body_response(text, scope=self.scope)
debug: File "/nix/store/ma1iqvarq124xyyq37knsgddzg9v7lqy-python3.12-oauthlib-3.2.2/lib/python3.12/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 427, in parse_request_body_response
debug: self.token = parse_token_response(body, scope=scope)
debug: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
debug: File "/nix/store/ma1iqvarq124xyyq37knsgddzg9v7lqy-python3.12-oauthlib-3.2.2/lib/python3.12/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response
debug: validate_token_parameters(params)
debug: File "/nix/store/ma1iqvarq124xyyq37knsgddzg9v7lqy-python3.12-oauthlib-3.2.2/lib/python3.12/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 448, in validate_token_parameters
debug: raise_from_error(params.get('error'), params)
debug: File "/nix/store/ma1iqvarq124xyyq37knsgddzg9v7lqy-python3.12-oauthlib-3.2.2/lib/python3.12/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 399, in raise_from_error
debug: raise cls(**kwargs)
warning: Failed to discover collections for calendar_redacted_remote, use `-vdebug` to see the full traceback.
john@mars:~/ > vdirsyncer --version
vdirsyncer, version 0.19.3
With these same credentials, if I run:
oauth2l fetch --credentials mail-redacted-oauth2.json \
--scope 'https://www.googleapis.com/auth/calendar' \
--cache= --output_format=json
I seem able to produce a token.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with vdirsyncer -vdebug discover, then read vdirsyncer/storage/google.py around _init_token and vdirsyncer/storage/dav.py around collection discovery. Compare the OAuth token response path with the reported oauth2l result and trace the exception handling. Done means first-time Google Calendar discovery no longer produces an unhandled stack trace and reports the failure clearly if token acquisition still fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, python
- Domain
- api, authentication, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100