java - 无法从 Office 365 门户打开我的应用程序。获取应用程序错误的未定义登录 URL

标签 java azure azure-active-directory adal adal4j

我正在将 Azure AD 登录身份验证集成到我的 Web 应用程序中。我已在 azure 开发门户中创建了一个帐户,并将我的应用程序注册为网络应用程序。在应用程序注册设置中,我提供了如下所示的重定向 URL,

重定向网址:https://mdb-dev-ext.xyzcde.com/my.dashboard/azureLogin.html

在我的 java web 应用程序中,我已经实现了在上述端点 (azureLogin.html) 中获取 azure token 的逻辑。我使用 ADAL java 库来实现以下代码逻辑

private AuthenticationResult acquireTokenByAuthorizationCode(String authCode) {
    String authority = System.getProperty("dashboard.azure.authority.url", "https://login.microsoftonline.com/xxxxxxxxxxxxxxxxxxx/oauth2/token");
    String clientId = System.getProperty("dashboard.azure.client.id", "xxxxxxxxxxxxxxxxxxxxxxxxx");
    String clientSecret = System.getProperty("dashboard.azure.client.secret", "xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    String redirectUrl = System.getProperty("dashboard.azure.redirect.uri", "https://mdb-dev-ext.xyzcde.com/my.dashboard/azureLogin.html?");
    AuthenticationResult result = null;
    ExecutorService service = null;
    try {
      service = Executors.newFixedThreadPool(1);
      AuthenticationContext context = new AuthenticationContext(authority, false, service);
      ClientCredential credential = new ClientCredential(clientId, clientSecret);
      Future<AuthenticationResult> future = context.acquireTokenByAuthorizationCode(authCode, URI.create(redirectUrl), credential, null);
      result = future.get();
    } catch (Exception e) {
      LOGGER.error("Error occurred while acquiring token from Azure {}", e.getMessage());
      throw new Exception(String.format("Error occurred while acquiring token from Azure. %s", e.getMessage()));
    }
    return result;
  }

注意:我没有提供“主页 URL”的值,我相信这不是强制性的

现在,在执行以下步骤时,我遇到了错误

登录portal.office.com

使用我的帐户凭据登录

登陆 Office 365 主页后,我可以看到列出的网络应用程序图标

单击我的网络应用程序的图标/按钮时,我被重定向并最终抛出以下错误。我的网络应用程序的服务器日志中没有日志更新。我确信这还没有到达我的网络应用程序。

"You cannot access this application because it has been misconfigured. Contact your IT department and include the following information:
Undefined Sign-On URL for application"

如果我为主页 URL 字段提供了 Web 应用程序的登录 URL,如下所示,

主页网址:https://mdb-dev-ext.xyzcde.com/my.dashboard

然后,当尝试从 Office 365 打开我的应用程序时,它会打开我的 Web 应用程序的登录页面(其中会提示输入应用程序的数据库用户名和密码)。这不是我要找的。

我想要实现的是 -> 登录 Office 365 -> 单击我的 Web 应用程序按钮 -> 应加载在我的应用程序注册期间在 Azure 门户中提到的重定向 URL -> 这最终将调用我的代码中编写的代码逻辑Web 应用程序获取 azure token 并使用存储在 session 中的 azure 返回的 token 登录我的应用程序。

请让我知道我在这里想念什么。为什么我收到此应用程序错误的未定义登录 URL?在 Office 365 门户中单击我的应用程序图标时,为什么它没有重定向到配置的重定向 URL?

最佳答案

Issue: "You cannot access this application because it has been misconfigured. Contact your IT department and include the following information: Undefined Sign-On URL for application"

关于该错误,您需要配置主页 url 才能修复该错误。更多详情请引用https://learn.microsoft.com/en-us/azure/active-directory/develop/registration-config-specific-application-property-how-to#brandingenter image description here

Issue: on click of my app's icon in office 365 portal, why it is not redirecting to >the redirect URL configured ?

关于这个问题,我认为您错过了有关登录 URL 和重定向 url 的信息。登录 URL 和重定向 URL 不同。通常,登录 URL 是触发 AAD 登录的 URL。重定向网址是应用程序成功授权后授权服务器将用户发送到的位置。

关于java - 无法从 Office 365 门户打开我的应用程序。获取应用程序错误的未定义登录 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58184035/

相关文章:

java - 列出我正在使用的每项 AWS 服务

java - 如何在java中使用NextLine()获取多个输入

java - Gradle使用不同的属性文件构建多个.war文件

java - jvm:是否有可能在关闭 Hook 中发现进程由于 OOM 而关闭?

powershell - 使用 PowerShell 获取 Azure DocumentDB 主键

azure - 在azure中公开非http端点

json - 您能否将 Blob 存储中的 JSON 文件的完整内容获取到 ADF 变量中?如果是这样,怎么办?

c# - 如何使用 Microsoft Graph .NET 客户端库清除字段

java - Azure 根据 Azure B2C Activity 目录验证 JWT token

azure - 如何获取 Microsoft Graph 读取 Excel 表格的 token ?