I am working on a Python based client code to access Microsoft Outlook 365 emails via OAuth2 and get all emails. But when I try to connect with my OAuth credentials, I get an UnauthorizedError
.
creds = OAuth2Credentials(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
tenant_id=TENANT_ID,
identity=Identity(primary_smtp_address='x@y'),
)
cfg = Configuration(
server='outlook.office365.com',
credentials=creds,
auth_type=OAUTH2,
)
#FIXME Following line attempts to create a session with EWS. Currently failing
account = Account(
primary_smtp_address='x@y',
config=cfg,
autodiscover=False,
access_type=DELEGATE,
)