Google calendar issue - Authentication code expired, please restart Home-Assistant and try again

I never got it to work, so I just gave up.

Hi, what was the problem you ran into?

The calendar integration is actively maintained (rewritten over the last few months) and definitely works.

If you hit any issues during token exchange, turning up debug logging like this may help:

logger:
  default: info
  logs:
    oauth2client: debug

The problem that caused me to give up was in the OAuth from Google.

I gave it another shot. The video by Jeff at Slacker Labs helped a lot with OAuth, and the instructions in Home Assistant helped me get the integration running.

Now, I just need to figure out how to use calendar events as a trigger.

Great. Check out Google Calendars - Home Assistant for some examples and links to more detail.

Hi Again.

I have followed the above Jeff’s video again and went through the google credentials setting all over again.
When all was set, I edited the configuration.yaml with the google id and secret, than restarted the system.
When rebooted, i didn’t get the notification for autorization.
so I went to settings - devices - add integration - google calendar
after some time appsed, the message authenticate the device did pop up.
i clicked the link, copied the code HA gave, and I was abble to allow acces to HA. Getting back to HA page, the Authentication code expired massage showed again.
So here I am, back at the square one…

Where should I check for error?
Is there some hardare limitaions (I am using a Rpi3)?

it is quite frustraiting not beeing able to set the calendar up, since this should be the main page on the wall mounted dasboard.

Yes, usually this means something is misconfigured.

Do you see errors or info in the logs?
What version of home assistant?

If you file an actual GitHub issue I can give you better help as it asks you for more information in the template.

The version I am using:
Home Assistant Core 2022.6.7
Home Assistant Supervisor 2022.05.3
Home Assistant OS 8.2

Waw, this time I got an error in the logs:

Logger: homeassistant
Source: components/google/api.py:123
First occurred: 2:53:28 PM (1 occurrences)
Last logged: 2:53:28 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/google/api.py”, line 123, in _poll_attempt
self._exchange_task_unsub()
TypeError: ‘NoneType’ object is not callable

Does this tell you something?
BR and thank you for the support till now!

Yes, that is very helpful. I saw this show up from one other report in Google Calendars - can't get authentication ¡ Issue #73484 ¡ home-assistant/core ¡ GitHub and so its helpful to hear about a second case.

Is this on a raspberry pi by chance?

(btw this says its a bug in home assistant that is on me to fix)

Yes, it runs on a raspberry pi 3.
So, do you have any suggestions from this point onward?
Can I give you some more info that will be useful for you?

Like I said above it’s a.bug. there is a solution in flight to try to fix it.

Hi Again,

since there were some updates in the meantime, I have tried again to add the google calendar integration.
This time, it gives a new error message. Maybe the error is still the same, just the message changed, maybe is a new thing.
image

Below is the error LOG file from the install attempt.

Hope it helps,

Logger: aiohttp.server
Source: components/google/api.py:189
First occurred: 1:26:30 PM (1 occurrences)
Last logged: 1:26:30 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 145, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 70, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 222, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 249, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data, init_done)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 336, in async_step_user
    return await self.async_step_pick_implementation(user_input)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 261, in async_step_pick_implementation
    return await self.async_step_auth()
  File "/usr/src/homeassistant/homeassistant/components/google/config_flow.py", line 88, in async_step_auth
    device_flow = await async_create_device_flow(
  File "/usr/src/homeassistant/homeassistant/components/google/api.py", line 189, in async_create_device_flow
    device_flow_info = await hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/oauth2client/client.py", line 1968, in step1_get_device_and_user_codes
    resp, content = transport.request(
  File "/usr/local/lib/python3.10/site-packages/oauth2client/transport.py", line 280, in request
    return http_callable(uri, method=method, body=body, headers=headers,
  File "/usr/local/lib/python3.10/site-packages/httplib2/__init__.py", line 1701, in request
    (response, content) = self._request(
  File "/usr/local/lib/python3.10/site-packages/httplib2/__init__.py", line 1421, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/usr/local/lib/python3.10/site-packages/httplib2/__init__.py", line 1343, in _conn_request
    conn.connect()
  File "/usr/local/lib/python3.10/site-packages/httplib2/__init__.py", line 1133, in connect
    sock.connect((self.host, self.port))
TimeoutError: [Errno 110] Operation timed out

This seems your server can’t open a connection to Google. Is it’s network healthy? Do you have ipv6 configured and It shouldn’t be?

So, the RPi, which is running HA, is connected directly to the modem of the service provider with a cable.
Till now, it had no network issues.
The system is not configured in IPv6, just IPv4, where I use a static IP (if it is of any concern).

Odd! Are you seeing connection issues to other cloud services? I’m curious if you can ping Google etc.

I believe, that the other cloud services work fine.
I am also using goolge drive backup with HA and I never had any errors while creating and coplying files to the drive.

OK – well this appears to be a network issue of some sort, so I would recommend checking firewall rules, adblockers, networking config. Not much insight i have from here.

Meanwhile, i’ve send a change to improve the error message so it displays something more friendly in the UI https://github.com/home-assistant/core/pull/75364

Thanks again for the support!
I will let you know if i manage to solve anything.
BR