From b63353da7f0f66e4f3474cf29cd1b3de421e766d Mon Sep 17 00:00:00 2001 From: Erik Cederstrand Date: Fri, 20 Dec 2024 15:23:33 +0100 Subject: [PATCH] chore: This is also an indication of an expired token. Refs #1345 --- exchangelib/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exchangelib/util.py b/exchangelib/util.py index 9a4e4590..7c9467a6 100644 --- a/exchangelib/util.py +++ b/exchangelib/util.py @@ -19,7 +19,7 @@ import requests.exceptions from defusedxml.expatreader import DefusedExpatParser from defusedxml.sax import _InputSource -from oauthlib.oauth2 import TokenExpiredError +from oauthlib.oauth2 import InvalidClientIdError, TokenExpiredError from pygments import highlight from pygments.formatters.terminal import TerminalFormatter from pygments.lexers.html import XmlLexer @@ -831,7 +831,7 @@ def post_ratelimited(protocol, session, url, headers, data, stream=False, timeou protocol.retire_session(session) log.debug("Session %s thread %s: connection error POST'ing to %s", session.session_id, thread_id, url) raise ErrorTimeoutExpired(f"Reraised from {e.__class__.__name__}({e})") - except TokenExpiredError: + except (InvalidClientIdError, TokenExpiredError): log.debug("Session %s thread %s: OAuth token expired; refreshing", session.session_id, thread_id) protocol.release_session(protocol.refresh_credentials(session)) raise