Skip to content

Commit

Permalink
fix: Add client_id and client_secret explicitly to session.post() to …
Browse files Browse the repository at this point in the history
…work around token refresh bug. Fixes #1090
  • Loading branch information
ecederstrand committed Aug 5, 2022
1 parent 5b6656d commit f7af5d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions exchangelib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from pygments import highlight
from pygments.formatters.terminal import TerminalFormatter
from pygments.lexers.html import XmlLexer
from requests_oauthlib import OAuth2Session

from .errors import (
InvalidTypeError,
Expand Down Expand Up @@ -839,10 +840,12 @@ def post_ratelimited(protocol, session, url, headers, data, allow_redirects=Fals
d_start = time.monotonic()
# Always create a dummy response for logging purposes, in case we fail in the following
r = DummyResponse(url=url, request_headers=headers)
kwargs = dict(url=url, headers=headers, data=data, allow_redirects=False, timeout=timeout, stream=stream)
if isinstance(session, OAuth2Session):
# Fix token refreshing bug. Reported as https://github.com/requests/requests-oauthlib/issues/498
kwargs.update(session.auto_refresh_kwargs)
try:
r = session.post(
url=url, headers=headers, data=data, allow_redirects=False, timeout=timeout, stream=stream
)
r = session.post(**kwargs)
except TLS_ERRORS as e:
# Don't retry on TLS errors. They will most likely be persistent.
raise TransportError(str(e))
Expand Down

0 comments on commit f7af5d9

Please sign in to comment.