rpaframework
rpaframework copied to clipboard
Add MFA support to RPA.Exchange.Email
Library RPA.Exchange.Email can't connect to Outlook Exchange server that has MFA enforced and gives just connection errors. The idea is to implement oauth support to retrieve the OTP number from another library like https://github.com/pyauth/pyotp.
More context here on this Slack thread. https://robotframework.slack.com/archives/C0115TMTADC/p1649872794578149
This got solved, here's an official Portal robot example on how to do it.
Hi @cmin764 , how can I use the OTP code on Authorize kw to login on Exchange email server?
I believe to have set everything right and when calling Authorize kw I get this error: KeyError: 'access_token'
Also, when I add "Library OAuth2" to my settings, I get this error: Importing library 'OAuth2' failed: ModuleNotFoundError: No module named 'OAuth2'
Hi there @AllanMedeiros ,
RPA.Email.Exchange.Authorize
is designed to work with one of these two:
-
App Password, passed with
password=
. (recommended and easy, MFA is required to be enabled on the account first) -
OAuth2, which is most secure, enabled with
is_oauth=${True} client_id=... client_secret=... token=...
. (this is a complex flow, you have to self-educate on this to understand what you're doing)
Here's a full Portal example you have to copy-paste into your robot (including the OAuth2.py library inside the root dir) before being able to use it. Please read all the instructions with maximum attention to the details, as you need to follow all the steps described in the README.
On the MFA side, we have another example which simply browser-automates the login flow with Selenium.
For more inquiries regarding the library, please use our forum instead.