使用OAuth在Office 365中使用Python创建帐户

使用OAuth在Office 365中使用Python创建帐户,python,authentication,oauth,Python,Authentication,Oauth,我正在尝试首先使用python连接到office 365,在那里我可以通过post请求点击office 365 api来创建帐户。我见过一些使用烧瓶和Django的溶液。但是,我只想在没有这些框架的情况下使用纯python脚本实现,只使用为此而构建的库。这是到烧瓶中溶液的链接: 完成api连接时: # Put your consumer key and consumer secret into a config file # and don't check it into github!

我正在尝试首先使用python连接到office 365,在那里我可以通过post请求点击office 365 api来创建帐户。我见过一些使用烧瓶和Django的溶液。但是,我只想在没有这些框架的情况下使用纯python脚本实现,只使用为此而构建的库。这是到烧瓶中溶液的链接:

完成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操作

如有任何建议或指导,将不胜感激。谢谢