Caldav google calendar problem

Configuration is the same as before with oauth, except you had to allow “insecure apps” in google - at least I did not find another way

How to find calendar ID

The most important in configuration:

caldavio:calendarName:url=https://apidata.googleusercontent.com/caldav/v2/calendar-id/events
caldavio:calendarName:oauth=true
# client_id for OAuth
caldavio:calendarName:username=client-id-for-oauth
# client_secret for OAuth
caldavio:calendarName:password=client-secret-for-oauth

This configuration works properly. Unfortunaly I have to allow insecure apps:

caldavio:GoogleMuellCal:url=https://www.google.com/calendar/dav/<calendar-id>/events
caldavio:GoogleMuellCal:username=<google username>
caldavio:GoogleMuellCal:password=<google user password>
caldavio:GoogleMuellCal:reloadInterval=15
caldavio:GoogleMuellCal:preloadTime=20000
caldavio:GoogleMuellCal:disableCertificateVerification=true

This one should work from my understanding …

caldavio:GoogleMuellCal:url=https://apidata.googleusercontent.com/caldav/v2/<calendar-id>/events
caldavio:GoogleMuellCal:username=<client-id-for-oauth>
caldavio:GoogleMuellCal:password=<client-secret-for-oauth>
caldavio:GoogleMuellCal:oauth=true
caldavio:GoogleMuellCal:reloadInterval=15
caldavio:GoogleMuellCal:preloadTime=20000
caldavio:GoogleMuellCal:disableCertificateVerification=true

… but it results in the following error message:

2018-06-10 21:10:52.854 [WARN ] [caldav.internal.job.EventReloaderJob] - Sardine error while loading calendar entries: Unexpected response (401 - Unauthorized)
com.github.sardine.impl.SardineException: Unexpected response
	at com.github.sardine.impl.handler.ValidatingResponseHandler.validateResponse(ValidatingResponseHandler.java:48) [234:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.handler.MultiStatusResponseHandler.handleResponse(MultiStatusResponseHandler.java:40) [234:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.handler.MultiStatusResponseHandler.handleResponse(MultiStatusResponseHandler.java:35) [234:org.openhab.io.caldav:1.12.0]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:218) [234:org.openhab.io.caldav:1.12.0]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:160) [234:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.execute(SardineImpl.java:962) [234:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.list(SardineImpl.java:417) [234:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.list(SardineImpl.java:409) [234:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.list(SardineImpl.java:386) [234:org.openhab.io.caldav:1.12.0]
	at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:246) [234:org.openhab.io.caldav:1.12.0]
	at org.openhab.io.caldav.internal.job.EventReloaderJob.execute(EventReloaderJob.java:137) [234:org.openhab.io.caldav:1.12.0]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh230]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh230]

I also get the same 401 unauthorized error with using the v2 API and OAuth. I am using the latest openHAB 2.3 snapshot. Is there a current workable solution using the Google v2 API are we stuck with v1 and insecure apps for the time being?

1 Like

Any update on this topic?

I also have problems with the 401 error.
The error appears every minute but the config is set to every 60minutes.

caldavio.cfg

Abfall:url=https://www.google.com/calendar/dav/<calenderID>@group.calendar.google.com/events
Abfall:username=<username-without-@gmail.com>
Abfall:password=<password>
Abfall:reloadInterval=60
Abfall:preloadTime=20000
Abfall:disableCertificateVerification=true
Abfall:timeZone=Europe/Berlin

The documentation says we need a caldavio: prefix but many users and every tutorial says it´s buggy.

caldavCommand.cfg and caldavPersonal.cfg are not configured.

Abfall.items

String calAbfallTonne "Tonne [MAP(muell.map):%s]" <tonne> {caldavPersonal="calendar:Abfall type:EVENT eventNr:1 value:NAME"}
String calAbfallMieter "Tonne [%s]" <tonne> {caldavPersonal="calendar:Abfall type:EVENT eventNr:1 value:DESCRIPTION"}
String calAbfall "Nächste Leerung [%s]" <tonne>
DateTime calAbfallDate "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar> {caldavPersonal="calendar:Abfall type:EVENT eventNr:1 value:START"}

Logfile warning:

2018-11-27 12:39:08.840 [WARN ] [caldav.internal.job.EventReloaderJob] - Sardine error while loading calendar entries: Unexpected response (401 - Unauthorized)
com.github.sardine.impl.SardineException: Unexpected response
2018-11-27 12:40:08.805 [WARN ] [caldav.internal.job.EventReloaderJob] - Sardine error while loading calendar entries: Unexpected response (401 - Unauthorized)
com.github.sardine.impl.SardineException: Unexpected response
2018-11-27 12:41:08.806 [WARN ] [caldav.internal.job.EventReloaderJob] - Sardine error while loading calendar entries: Unexpected response (401 - Unauthorized)
com.github.sardine.impl.SardineException: Unexpected response
2018-11-27 12:42:08.798 [WARN ] [caldav.internal.job.EventReloaderJob] - Sardine error while loading calendar entries: Unexpected response (401 - Unauthorized)
com.github.sardine.impl.SardineException: Unexpected response
	at com.github.sardine.impl.handler.ValidatingResponseHandler.validateResponse(ValidatingResponseHandler.java:48) [227:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.handler.MultiStatusResponseHandler.handleResponse(MultiStatusResponseHandler.java:40) [227:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.handler.MultiStatusResponseHandler.handleResponse(MultiStatusResponseHandler.java:35) [227:org.openhab.io.caldav:1.12.0]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:218) [227:org.openhab.io.caldav:1.12.0]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:160) [227:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.execute(SardineImpl.java:962) [227:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.list(SardineImpl.java:417) [227:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.list(SardineImpl.java:409) [227:org.openhab.io.caldav:1.12.0]
	at com.github.sardine.impl.SardineImpl.list(SardineImpl.java:386) [227:org.openhab.io.caldav:1.12.0]
	at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:246) [227:org.openhab.io.caldav:1.12.0]
	at org.openhab.io.caldav.internal.job.EventReloaderJob.execute(EventReloaderJob.java:137) [227:org.openhab.io.caldav:1.12.0]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh230]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh230]

The credentials are correct and i´m able to download the entries with a browser.

kind regards
Michael

Hi,

Sorry, i am not using the Google calendar. I Just tested it maybe 2 years ago.
The warn Message appears every Minute because of the failure.
Your configuration Looks good. Isn’t Somebody Here who is using caldav with Google?

Hi,

I configured the binding with Google a year ago and it worked with some restriction.
Allow insecure apps in Google configuration.
The configuration is shwon below:

addons.cfg:

binding = caldav-command1, caldav-personal1

caldavPersonal.cfg

caldavPersonal:usedCalendars=Rollladensteuerung

caldavCommand.cfg

caldavCommand:readCalendars=Rolladensteuerung

caldavio.cfg

caldavio:Rolladensteuerung:url=https://www.google.com/calendar/dav/<id>@group.calendar.google.com/events
caldavio:Rolladensteuerung:username=<username-without-@gmail.com>
caldavio:Rolladensteuerung:password=<password>
caldavio:Rolladensteuerung:reloadInterval=1
caldavio:Rolladensteuerung:preloadTime=18720
caldavio:Rolladensteuerung:disableCertificateVerification=true
caldavio:timeZone=Europe/Berlin

As I recall, a warning or error appeared after shifting calender entries.

Hi there,

i use this ol topic because I have an issue with the caldav binding.

I configured it and it worked for two days. Now I get an 401 error. But not with the calender I want to use.
I had serveral configurations and I deleted all exept one. This is working. But the errors are from an old configuration that I dont use.
I cleaned the cache with no result.and a restart didnt solve the problem as well.

Has someone an idea?

I had the same problem. Tried to fix it by the hints in the forum. It was not a OH / CALDAV configuration problem but a Google security issue.
I had to allow less secure Apps in my google accout https://myaccount.google.com/lesssecureapps

Now everything is working fine … but with less security