Google calendar requires re-authorization every 24 hours.
While running without problems for month, since a few days google calendar integration stops working once a day. There were no changes in the configuration, there might have been an update in HACS components.
Lovelace reports "The calendar can't be loaded from Home Assistant component.".
After removing .google.token and restarting home assistant I get a notification "In order to authorize Home-Assistant to view your calendars you must visit: https://www.google.com/device and enter code: xxx-xxx-xxx", after doing that everything is fine again.
configuration.yamlgoogle:
client_id: xxx-xxx.apps.googleusercontent.com
client_secret: xxxx
The calendar can't be loaded from Home Assistant component
google_calendar documentation
google_calendar source
(message by IssueLinks)
Still happening in 0.117.0.
Deleting the .google.token file, restarting HA and re-authenticating kicks it over again for 24hrs.
Same here!`
arch | x86_64
-- | --
chassis | vm
dev | false
docker | true
docker_version | 19.03.11
hassio | true
host_os | HassOS 4.15
installation_type | Home Assistant OS
os_name | Linux
os_version | 5.4.72
python_version | 3.8.6
supervisor | 2020.10.0
timezone | Europe/Amsterdam
version | 0.117.0
virtualenv | false
Thought I was going insane. Same here. Wondering if I should just switch to calDAV or other methods. Google Calender has these authentication issues coming and going too much for my taste..
For me the problem has disappeared - without changing anything. There seems to have been an error with Google, everything is currently working again.
Update: Not running again yet. The calendar integration is still occasionally lost. Not every 24 hours, but possibly related to HA reboots. And with incorrectly "} 2client.client"} at the end of the .google.token.
Mine hasn鈥檛. Deleted the .google file again and reauthenticated yesterday (for the 3rd day). Today it was showing the error again.
Trying again today, see if it stays or not..
I have a similar issue since 0.116. It seems that the _.google.token_ file gets garbled during home assistant restarts sometimes and then cannot be used to refresh the token leading to the same error message.
The file does not contain valid json then. At the end of the file where the JSON object is closed there is some trailing stuff:
... "invalid": false, "_class": "OAuth2Credentials", "_module": "oauth2client.client"}2client.client"}
Had this twice in the last 2-3 weeks and only happened when I restarted HA even though I triggered the restart from the HA UI and not by restarting the system/container.
google_calendar documentation
google_calendar source
(message by IssueLinks)
Both links are 404... great bot 馃憤
@jo-me You're right... removing that part and reloading the frontend brings back the calendar for me.
But reboot doesn't seem to be the problem in my case - it mostly happens over night without any reboots.
Quick and dirty workaround - run this shell_command once in a while (it removes the trailing stuff):
shell_command:
google_token: sed -i -e 's/2client.client"}2client.client"}/2client.client"}/g' /config/.google.token
Thanks!
OK, quick hack from @noxhirsch works, but we need a dev to understand root cause and fix.
Most helpful comment
Quick and dirty workaround - run this shell_command once in a while (it removes the trailing stuff):