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

Workaround was found on GIT:

Worked for me to set timezone for configuration to etc/GMT, after configuration, I reset this to my acual one.
Happy day :slight_smile:

11 Likes

Thanks that fixed it for me too

2 Likes

Thanks @naibaf! I’ve had calendar integration working for some time and using it in various automations and dashboards. When it failed I had no idea but the timezone change fixed things.

2 Likes

Thank you for the trick.
I went to Configuration > General and manually changed from Europe/Paris to Etc/GMT.
Saved and restarted HA.
This time the Google code showed up as expected in the Notification menu :slight_smile:

5 Likes

Another thing : in /config/google_calendars.yaml , I added max_results: 50 under (and only under) my personal email like so

- cal_id: [email protected]
  entities:
  - device_id: john_smith
    ignore_availability: true
    name: John Smith
    track: true
    max_results: 50

otherwise I had only 5 events showing in the calendar in HA

I went to Configuration > General and manually changed from Europe/Paris to Etc/GMT.
Saved and restarted HA.
This time the Google code showed up as expected in the Notification menu . Once all configured, changed it back to my timezone.

This worked for me too. Thanks everyone for the inputs.

Had exactly the same issue.
Changed Configuration > General > TZ from Europe/Paris to Etc/GMT.
Hope this gets solved in an upcoming release.

Tried the above suggested methods, worked for 2 days after that the message appeared again. Tried to resolve the issue by changing again the TimeZone (TZ) but no success this time. Error keeps appearing, hope indeed that this is an issue that can be resolved.

Thank You That worked for me. Just changing TImezone able to see Calendar in HA

I tried the trick

  • Configuration > General > TZ = Etc/GMT
  • Save
  • Supervisor > System > Reboot Host

And it did not work for me. And it worked :slight_smile:
Versions: core-2021.8.8 | supervisor-2021.06.8 | Home Assistant OS 6.2

One thing though, I believe nobody yet noted is. That for me the code was briefly shown.

  • 16:00:00 - Reboot host
  • 16:02:00 - Browser HAss web interface is loaded - with the following message (normal) - no notification yet shown

Starting automation, not everything will be available until it is finished.

  • 16:02:12 - Notification is shown with the following text

…er to authorize Home-Assistant to view your calendars you must visit: Sign in - Google Accounts and enter code: XXX-XXX-XXX
1 second ago

But then after about 3-5 seconds the text in the notification changes to the following message

Authentication code expired, please restart Home-Assistant and try again.

So maybe it is a Time to live issue with the code?

I tried to be quick and paste it, but as there are another click through screens after you insert the code, I did not manage to fill it and click through them in the 5 seconds before I get the expired error.

So then I tried the trick with the timezone change and it worked. The code stayed there, and worked.

The underlying issue here has been fixed. But the fix will most likely not be available until 2021.9.0 is released.

Works for me :crossed_fingers:

  • Changed time zone to Utc/GMT and save
  • restarted Hass server
  • Got Hass notification with code which I entered on google.com/device
  • Followed the authentication steps
  • Got another Hass notification that everything is ok and file google-calendar.yaml has been created
    Thanks @naibaf and everybody

Thanks for this fix. I had the same issue just now, in version 2021.11.5 (despite the github issue being marked as closed).

Doesn’t look to be fixed yet, but at least I’ve added the timezone trick in the official doc in the troubleshooting section :slight_smile:

Hi Community,

These days I am also trying to set up the Google calendar in HA.
Unfortunately, get the same error as all above mentioned.
I also have the “misfortune” to run the latest version of HA (2022.6.5), where the Time zone settings were changed (i don’t know relay on which version they changed it).
The result is, that the etc/GMT is not available anymore.

Any idea of a new workaround this?

BR

Quick update:

I have managed to edit the configuration.yaml file to insert the Etc/GMT Time zone::

homeassistant:
  time_zone: Etc/GMT

Now the option to select the desired TZ in the settings – system – general is disabled.
However, I still can’t install the google calendar integration…

For those who already installed the calendar. Does it still work? Is it just an installation problem?

BR

I have the same problem, with the calendar intergration, not being authenticated.

Have tried almost all time zones, restarting and attempting to reauthenticate to no avail, still receive the same error message.

Kind regards

The error above no longer exists and was removed from the integration – if you’d like help supply some additional detail.

OK, so in my case, i have followed these instructions Google Calendars - Home Assistant
Got my Client ID, Client Secret from google and all the neccessary settings done.
Then in HA went on settings – device & services – add integration – google calendar
After some time of Please wait while Google Calendars is being setup, I get the message

I enter the displayed code into the google account. I get the confirmation message that the device was linked. I also receive the email that a new device was granted the access to the calendar.

So far so good, unfortunately, in HA I get the message the code expired
image

This is as far I have come with the installation.

Have any information in the logs? This usually indicates an error with the credentials.