RogerSelwyn / MS365-Calendar

Microsoft 365 Calendar Integration for Home Assistant
MIT License
9 stars 1 forks source link

I keep getting O365 calendar related errors several times a day #23

Closed smarthomefamilyverrips closed 1 week ago

smarthomefamilyverrips commented 1 week ago

I keep getting the below errors, I already did try reload of integration, restart of HA, renewed token but errors keep popping up

This error originated from a custom integration.

Logger: homeassistant Source: custom_components/ms365_calendar/integration/calendar_integration.py:611 integration: Micosoft 365 - Calendar (documentation, issues) First occurred: 22:02:30 (1 occurrences) Last logged: 22:02:30

Error doing job: Task exception was never retrieved (None) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/calendar/trigger.py", line 255, in _handle_refresh self._events.extend(await self._fetcher(self._timespan)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/calendar/trigger.py", line 133, in async_get_events active_events = await fetcher(offset_timespan) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/calendar/trigger.py", line 115, in async_get_events return await entity.async_get_events(hass, timespan.start, end_time) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ms365_calendar/integration/calendar_integration.py", line 264, in async_get_events return await self.data.async_get_events(hass, start_date, end_date) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ms365_calendar/integration/calendar_integration.py", line 622, in async_get_events results = await self.async_ms365_get_events(hass, start_date, end_date) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ms365_calendar/integration/calendar_integration.py", line 546, in async_ms365_get_events events = await self._async_calendar_schedule_get_events( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ms365_calendar/integration/calendar_integration.py", line 611, in _async_calendar_schedule_get_events return await hass.async_add_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/calendar.py", line 1797, in get_events response = self.con.get(url, params=params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 898, in get return self.oauth_request(url, 'get', params=params, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 887, in oauth_request return self._internal_request(self.session, url, method, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 848, in _internal_request raise HTTPError('{} | Error Message: {}'.format(e.args[0], error_message), requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://graph.microsoft.com/v1.0/me/calendars/AQMkADAwATNiZmYAZC03YmEzLTk2YmIALTAwAi0wMAoARgAAA-MMqasDrAtHnQgbr2JjCCQHABD9WdJWyYBIm2HB8Vb0nAMAAAIBBgAAABD9WdJWyYBIm2HB8Vb0nAMAAABJuzatAAAA/calendarView?%24top=999&startDateTime=2024-09-17T22%3A01%3A16.786065%2B03%3A00&endDateTime=2024-09-17T22%3A16%3A17.786934%2B03%3A00&%24select=location%2Csubject%2Cend%2CseriesMasterId%2Cattendees%2CshowAs%2Cbody%2Csensitivity%2CisAllDay%2Ccategories%2Cstart | Error Message: IDX14100: JWT is not well formed, there are no dots (.). The token needs to be in JWS or JWE Compact Serialization Format. (JWS): 'EncodedHeader.EncodedPayload.EncodedSignature'. (JWE): 'EncodedProtectedHeader.EncodedEncryptedKey.EncodedInitializationVector.EncodedCiphertext.EncodedAuthenticationTag'.

And Logger: O365.connection Source: /usr/local/lib/python3.12/site-packages/O365/connection.py:838 First occurred: 22:02:30 (1 occurrences) Last logged: 22:02:30

Client Error: 401 Client Error: Unauthorized for url: https://graph.microsoft.com/v1.0/me/calendars/AQMkADAwATNiZmYAZC03YmEzLTk2YmIALTAwAi0wMAoARgAAA-MMqasDrAtHnQgbr2JjCCQHABD9WdJWyYBIm2HB8Vb0nAMAAAIBBgAAABD9WdJWyYBIm2HB8Vb0nAMAAABJuzatAAAA/calendarView?%24top=999&startDateTime=2024-09-17T22%3A01%3A16.786065%2B03%3A00&endDateTime=2024-09-17T22%3A16%3A17.786934%2B03%3A00&%24select=location%2Csubject%2Cend%2CseriesMasterId%2Cattendees%2CshowAs%2Cbody%2Csensitivity%2CisAllDay%2Ccategories%2Cstart | Error Message: IDX14100: JWT is not well formed, there are no dots (.). The token needs to be in JWS or JWE Compact Serialization Format. (JWS): 'EncodedHeader.EncodedPayload.EncodedSignature'. (JWE): 'EncodedProtectedHeader.EncodedEncryptedKey.EncodedInitializationVector.EncodedCiphertext.EncodedAuthenticationTag'. | Error Code:

RogerSelwyn commented 1 week ago

I would delete the token and re-authenticate, it looks like the token is corrupt. If it keeps happening I would check if there is some sort of problem with your file system.

smarthomefamilyverrips commented 1 week ago

@RogerSelwyn I had similar issues here with the 0365 integration, and also now it started to happen again after latest update to v0.1.3

https://github.com/RogerSelwyn/O365-HomeAssistant/issues/242

smarthomefamilyverrips commented 1 week ago

I would delete the token and re-authenticate, it looks like the token is corrupt. If it keeps happening I would check if there is some sort of problem with your file system.

I did do this already using the reconfigure option

smarthomefamilyverrips commented 1 week ago

@RogerSelwyn as stated above the errors did start coming after update to v0.1.3

RogerSelwyn commented 1 week ago

Sorry, no idea. The other errors you linked also suggest instability in your setup (which I suggested there).

There is a suggestion elsewhere that it could be the time changing on your system. Another thing you can check is that you have granted offline_access permissions to the azure pp.

The comment I would make is that with several thousands of users of the various integrations all using the same authentication method, the likely issue is on your system, not in the code.

The fact that the errors occur intermittently, suggests something is changing in your setup some way, some how. I'm afraid I can't diagnose the problem.

RogerSelwyn commented 1 week ago

@RogerSelwyn as stated above the errors did start coming after update to v0.1.3

Please roll back to the working version, and confirm the issue is resolved. Then I will investigate more.

smarthomefamilyverrips commented 1 week ago

I can just rollback using the redownload option in HACS without any problem?

RogerSelwyn commented 1 week ago

Depends what version of HACS you are using I think, you will need to google it if you can't see how.

smarthomefamilyverrips commented 1 week ago

2.0 HACS, I know how to re-download a older version. I just was asking if will not be a problem to put a old version over the newer one

RogerSelwyn commented 1 week ago

It will be fine

smarthomefamilyverrips commented 1 week ago

Ok thank you, I will keep you updated

smarthomefamilyverrips commented 1 week ago

Same on v0.1.2, but I actually think I did update from v0.1.1 to v0.1.3, when time will give it a other try. Thanks!

smarthomefamilyverrips commented 1 week ago

I will close this for now as I not have the time to look in it further at the moment and errors keep coming I will temporarily switch to using ICS Calendar and come back to this on a later point in time.