Skip to content

Commit

Permalink
No need to monkeypatch updated exchangelib (OAuth2)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmin764 committed Aug 10, 2022
1 parent 652de00 commit 992aa81
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
17 changes: 0 additions & 17 deletions ExtendedExchange.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
import functools

from RPA.Email.Exchange import Exchange
from RPA.Robocorp.Vault import Vault
from exchangelib.services import common as exchangelib_common
from exchangelib.util import post_ratelimited


vault = Vault()


def extended_post_ratelimited(protocol, session, *args, **kwargs):
session.post = functools.partial(
session.post,
client_id=protocol.credentials.client_id,
client_secret=protocol.credentials.client_secret,
)
return post_ratelimited(protocol, session, *args, **kwargs)

# Monkey-patching infinite loop fix on token refresh, due to OAuth2 library bug when
# passing the app credentials to the "/token" endpoint.
exchangelib_common.post_ratelimited = extended_post_ratelimited


class ExtendedExchange(Exchange):

def __init__(self, *args, secret_name, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ dependencies:
# Define pip packages here.
# https://pypi.org/
- PyJWT==2.4.0
- exchangelib==4.7.3
- rpaframework==15.2.0 # https://rpaframework.org/releasenotes.html
- rpaframework==15.7.0 # https://rpaframework.org/releasenotes.html

0 comments on commit 992aa81

Please sign in to comment.