首页 > 解决方案 > Flask Make Azure Blueprint - 得到一个意外的参数“租户”

问题描述

我正在尝试使用 Azure Active Directory 来允许我公司的 Microsoft 域中的用户登录到我的 Flask webapp。我收到一条错误消息:

消息:AADSTS90130:应用程序 ... 不受 /common 或 /consumers 端点的支持。请使用 /organizations 或特定于租户的端点。

所以我做了一些研究,发现这个文档说我可以设置一个“租户”参数,但是当我运行这个时:

blueprint = make_azure_blueprint(
    client_id="client_id_here",
    client_secret="client_secret_here",
    tenant="tenant_here"
)

我收到一个错误:

TypeError:make_azure_blueprint() 得到了一个意外的关键字参数“租户”

有谁知道我做错了什么?如何在 Flask Dance 中设置 Azure 租户?

标签: pythonazureflaskazure-active-directory

解决方案


如果其他人遇到这个问题:我发现默认情况下库实际上并不包含租户参数。您可以通过简单地进入烧瓶舞蹈库中的 azure.py 文件并将两行更改为读取来添加它:

authorization_url="https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize".format(tenant=tenant),
token_url="https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token".format(tenant=tenant),

推荐阅读