首页 > 解决方案 > 将 django-microsoft-auth 用于 Azure AD 的 SSO 时出现 AADSTS90102 错误

问题描述

我按照本教程中的步骤为我的 Django 应用程序的管理部分(启动)启用了 Azure Active Directory 的 SSO: https ://django-microsoft-auth.readthedocs.io/en/latest/usage.html

导航到 /admin 会产生这个页面,这很好: 在此处输入图像描述

单击 Microsoft 会打开这个新窗口: 在此处输入图像描述

重要的错误似乎是:AADSTS90102:“redirect_uri”值必须是有效的绝对 URI。

在这个窗口中,我使用浏览器控制台,发现正在发出一个 GET 请求,如下所示:

https://login.microsoftonline.com/50ce...90ac7/oauth2/v2.0/authorize?response_type=code&client_id=f4...27&redirect_uri=https,https://example.org/microsoft/auth-callback/&s...

注意redirect_uri=https,https://.... 似乎领先的“https”是多余的并且导致了问题。任何想法可能来自哪里?

在我的 Azure 应用程序中,重定向 URI 设置为https://example.org/microsoft/auth-callback/在此处输入图像描述

我正在使用 Python 3.9.6、Django 3.2、django-microsoft-auth 2.4.0、NGINX 1.18.0、uvicorn 0.14.0

我已经为此寻求帮助,但没有找到与我的情况相关的任何内容。提前致谢!

标签: pythondjangoazureazure-active-directorysingle-sign-on

解决方案


基于 SO 线程参考。

在大多数情况下,使用 http 作为重定向 URI 而不是 https 来解决问题。

利用

http://localhost:8080/microsoft/auth-callback/

代替

https://localhost:8080/microsoft/auth-callback/

如果有选项,

使用 localhost:8080 进入表 django_site

参考 SO 线程:django-microsoft-auth:为输入参数“redirect_uri”提供的值无效


推荐阅读