首页 > 解决方案 > AADSTS50011:请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配:

问题描述

msal用来验证用户。

我的userAgentApplication样子是这样的:

var userAgentApplication = new UserAgentApplication({
  auth: {
    clientId: config.appId,
    authority: config.authority,
    validateAuthority: false,
  },
  cache: {
    cacheLocation: "localStorage",
    storeAuthStateInCookie: true,
  },
});

这是我的config.js

modules.exports = {
    appId: "<my-App-id>",
    authority:
      "https://login.microsoftonline.com/<my-Tenant-id>/",
    scopes: ["user.read", "calendars.read"],
  };

我一直遇到这个错误,我不知道为什么会这样。

Request Id: 38b5b62e-0407-4520-8319-157b9c2e3e00
Correlation Id: 143c20c5-4cab-41be-aded-14daa783d022
Timestamp: 2020-04-06T07:21:35Z
Message: AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application: 'xxxxxxxxxx'.

标签: javascriptmicrosoft-graph-apimsalmsal.js

解决方案


auth.redirectUri实例化时如果不设置UserAgentApplicationmsal会使用当前页面的url作为redirectUri每个请求设置的url,使用的页面redirectUri都必须在Azure Portal中注册。您需要设置auth.redirectUri为在 Azure 门户中注册的 url,或者将应用程序中的所有页面注册为可能的重定向 uri(可能不太可取)。


推荐阅读