python-o365: JWT is not well formed, there are no dots
I have a few people who use the Home Assistant O365 integration that are getting the errors as shown below (they are encapsulated in HA login, but you can see what is being surfaced by O365). I’ve only seen reports in the last few months, but I have no idea what is causing them. Unfortunately I don’t get the problem myself (or just don’t notice the error in my logs, so I don’t really know what triggers it).
Any ideas as to what is causing the problem? The integration sets up a FileSystemTokenBackend, which it uses I the Account setup call, beyond that it leaves token management to O365 (apart from reading the token once to check granted permissions). Code as below:
def _try_authentication(perms, credentials, main_resource):
_LOGGER.debug("Setup token")
token_backend = FileSystemTokenBackend(
token_path=perms.token_path,
token_filename=perms.token_filename,
)
_LOGGER.debug("Setup account")
account = Account(
credentials,
token_backend=token_backend,
timezone=CONST_UTC_TIMEZONE,
main_resource=main_resource,
)
try:
return account, account.is_authenticated
except json.decoder.JSONDecodeError:
return account, False
Logger: custom_components.o365.calendar
Quelle: custom_components/o365/calendar.py:655
Integration: Office 365 (Dokumentation, Probleme)
Erstmals aufgetreten: 08:48:54 (1 Vorkommnisse)
Zuletzt protokolliert: 08:48:54
Error getting calendar events - 401 Client Error: Unauthorized for url: https://graph.microsoft.com/v1.0/me/calendars/AQMkADAwATNiZmYAZC04M2ZhLTkwNDYtMDACLTAwCgBGAAADxUpIqt1PQ02qEe37a0cywQcAe9JyutQAp0a3sg19Hw9tFgAAAgEGAAAAe9JyutQAp0a3sg19Hw9tFgAF1RvVAwAAAA==/calendarView?%24top=999&startDateTime=2024-11-08T07%3A48%3A44.399251%2B00%3A00&endDateTime=2024-11-09T07%3A48%3A44.399274%2B00%3A00&%24select=sensitivity%2Cstart%2Ccategories%2Cbody%2CisAllDay%2Csubject%2Cend%2Clocation%2CseriesMasterId%2Cattendees%2CshowAs | 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'.
Logger: O365.connection
Quelle: /usr/local/lib/python3.12/site-packages/O365/connection.py:838
Erstmals aufgetreten: 08:48:54 (1 Vorkommnisse)
Zuletzt protokolliert: 08:48:54
Client Error: 401 Client Error: Unauthorized for url: https://graph.microsoft.com/v1.0/me/calendars/AQMkADAwATNiZmYAZC04M2ZhLTkwNDYtMDACLTAwCgBGAAADxUpIqt1PQ02qEe37a0cywQcAe9JyutQAp0a3sg19Hw9tFgAAAgEGAAAAe9JyutQAp0a3sg19Hw9tFgAF1RvVAwAAAA==/calendarView?%24top=999&startDateTime=2024-11-08T07%3A48%3A44.399251%2B00%3A00&endDateTime=2024-11-09T07%3A48%3A44.399274%2B00%3A00&%24select=sensitivity%2Cstart%2Ccategories%2Cbody%2CisAllDay%2Csubject%2Cend%2Clocation%2CseriesMasterId%2Cattendees%2CshowAs | 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:
The user has checked their access token. There are no dots inside. They’ve also checked it with jwt.io and get the following error:
Error: Looks like your JWT Header is not encoded correclty using base64url (https://tools.ietf.org/html/rfc4648#section-5). Note that padding ("=") must be omitted as per https://tools.ietf.org/html/rfc7515'section-2
The error does not occur permanently, but only occasionally. It then seems to heal itself, since the synchronization of tasks and calendar generally works.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 194 (188 by maintainers)
I’d agree. I considered that max_tries would be doing nothing otherwise 😃
I can re-open/open new if I need to
I’ll try and look at documentation tomorrow, if I don’t get any other bugs in tomorrow. I’m getting more interest in my HA stuff, which is generating more work for me.
Happy to, just ping when you have it ready. You can have my email if you prefer.
I’ve run this through my test suite, and it tests fine.
Hiya, I’ll do some checking of what calls I’m making and the parameters passed, and get back to you. Maybe later or tomorrow morning.
Thanks
retreive the state saved in auth_step_one -
retreiveshould beretrieveas it’s asuming there is are no parallel connections running at once - should beassumingYou have written this in the readme
It is highly recommended to add the "offline_access" permission. Otherwise the library will only have access to the user resources for 1 hour. See [Permissions and Scopes](#permissions-and-scopes).I don’t think you can add
offline_access, if you do, you will get this error:Soon!
Done as well.
After the testing I will release asap
I’m away, may be able to test Sunday/Monday.