无法连接到Exchange:401客户端错误:未经授权的网址:https://outlook.office365.com/EWS/Exchange.asmx
from pyexchange import Exchange2010Service, ExchangeNTLMAuthConnection
from pytz import timezone
from datetime import datetime
URL = u'https://outlook.office365.com/EWS/Exchange.asmx'
USERNAME = u'user@abc.com'
PASSWORD = u"password"
# Set up the connection to Exchange
connection = ExchangeNTLMAuthConnection(url=URL,
username=USERNAME,
password=PASSWORD)
service = Exchange2010Service(connection)
# List all events from date to date
calendar_list = service.calendar().list_events(
start=timezone('Europe/Amsterdam').localize(datetime(2020, 7, 1)),
end=timezone('Europe/Amsterdam').localize(datetime(2020, 10, 30)),
details=True
)
for event in calendar_list.events:
print("{start} ------ {stop} ------ {subject}".format(
start=event.start,
stop=event.end,
subject=event.subject
))
感谢您的帮助