-
-
Notifications
You must be signed in to change notification settings - Fork 364
Description
Upgrading from version 2.5.5 to 2.6.2 of office365-rest-python-client causes a TypeError during authentication when using certificate-based access tokens. The error occurs due to a comparison between a timezone-naive and a timezone-aware datetime object in the _authenticate method.
To Reproduce Steps to reproduce the behavior:
Use certificate-based authentication with ConfidentialClientApplication and ClientContext.with_access_token(...).
Attempt to upload a file to SharePoint using ctx.execute_query().
Observe the following traceback:
TypeError: can't compare offset-naive and offset-aware datetimes
File "...\authentication_context.py", line 186, in _authenticate
if self._cached_token is None or request_time > self._token_expires:
Expected behavior Datetime comparisons should be consistent — either both timezone-aware or both naive — to avoid runtime errors.
Environment:
Python 3.11
office365-rest-python-client 2.6.2
OS: Windows 11
Additional context This issue did not occur in version 2.6.1. It appears that internal changes in how token expiration is handled introduced stricter datetime comparisons.