【发布时间】:2020-08-08 14:52:46
【问题描述】:
我正在尝试实施 oAuth 流程以使用 Microsoft 登录。 我有以下端点: https://login.microsoftonline.com/common/oauth2/v2.0/authorize https://login.microsoftonline.com/common/oauth2/v2.0/token
我的流程是这样的: 单击“使用 Microsoft 登录”按钮重定向到 Microsoft:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id={client_id}&scope=user.read&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F1%2Ffrontend%2Flogin%3Fstate%3Dtest
我的重定向网址是:
http://localhost:8000/1/frontend/login?state=test
附有我从 Microsoft 收到的代码。
然后我向 /token 端点执行 POST 请求。 但是,我收到一条错误消息 (AADSTS50011):
AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application:
我发送的数据是正确的,除了redirect_uri。我有以下值:
http%3A%2F%2Flocalhost%3A8000%2F1%2Ffrontend%2Flogin%3Fstate%3Dtest
这只是我的重定向 url 的 url 编码版本,包括 ?state=test
我知道除了redirect_uri 之外一切正常,因为当我删除状态查询参数时,一切正常。 但是,要在我的应用程序中正确路由 redirect_uri,我需要 state 参数。 我无法在我的应用程序设置中添加它,我必须将它包含在第一个请求中(/授权端点) 一切正常,但第二个(/token)POST 请求失败,我无法使用 ?state= 参数输入我的 redirect_uri。 我尝试了几个选项,例如对 redirect_uri 进行编码,但没有帮助。
所有其他 oAuth 流程(如 Github)都运行良好。微软除外。
【问题讨论】: