我正在尝试使用python首先连接到office 365,我可以通过发布请求创建帐户来访问办公室365 api。我已经看到使用Flask和Django的一些解决方案。但是,我想在没有这些框架的情况下使用纯python脚本来实现,只使用为此而构建的库。这是Flask中解决方案的链接:https://dev.office.com/code-samples-detail/5989
api连接完成的地方:
# Put your consumer key and consumer secret into a config file
# and don't check it into github!!
microsoft = oauth.remote_app(
'microsoft',
consumer_key=client_id,
consumer_secret=client_secret,
request_token_params={'scope': 'User.Read Mail.Send'},
base_url='https://graph.microsoft.com/v1.0/',
request_token_url=None,
access_token_method='POST',
access_token_url='https://login.microsoftonline.com/common/oauth2/v2.0/token',
authorize_url='https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
)
此外,与Flask解决方案不同,我不会使用任何视图,但它主要作为后端任务运行。
我想仅使用Python OAuth库复制api连接,因此它作为Python脚本运行。到目前为止,我在尝试curl或使用request_oauth时只收到403错误。一旦我连接到api,我就可以对帐户执行CRUD操作。
任何建议或指导将不胜感激。感谢。