【问题标题】:Issues with retrieving access token when using adal.js 1.0.17使用 adal.js 1.0.17 时检索访问令牌的问题
【发布时间】:2019-09-06 06:36:01
【问题描述】:

我正在使用下面的example 来配置一个带有 1.0.17 版 adal.js 的简单应用程序。在本地启动页面时,我能够成功运行此示例并验证用户身份 (http://localhost:8000/simpleSPA.html)。但是,当 simpleSPA.html 从托管它的服务器返回给调用者时(访问特定 URL 时),我遇到了身份验证问题。在 simpleSPA.html 中调用 API 失败,因为令牌未定义。我已经监控了提琴手中的请求,并注意到只有一个对 /common/oauth2/authorize 的 GET 请求,其中 response_type 是 id_token:

GET /common/oauth2/authorize?response_type=id_token&client_id=[client_id]&redirect_uri=[url that returns simplspa.html]&state=[state id]&client-request-id=[request id]&x-client-Ver=1.0.17&nonce=893886e6-4042-4059-9dc7-ae8acf2af792 HTTP/1.1

当我在 localhost 上运行同一页面时,我看到了 2 个请求:首先我看到了对 /common/oauth2/authorize 的 GET 请求,其中 response_type 是 id_token。

第二个是对 /common/oauth2/authorize 的 GET 请求,其中 response_type 是令牌

GET /common/oauth2/authorize?response_type=token&client_id=[client id]&resource=[resource]&redirect_uri=[url that returns simplespa.html]&state=[state id]&client-request-id=[client request id]&prompt=none&login_hint=testuser.domain***.onmicrosoft.com&domain_hint=[domain] HTTP/1.1

我确认已为 Azure 上的客户端应用启用了访问令牌和 ID 令牌。 所以我的目标是了解为什么在本地运行页面会导致检索访问令牌。最好知道在我描述的场景中阻止获取访问令牌的条件。提前感谢您提供任何有助于我调查此问题的想法!

【问题讨论】:

    标签: adal adal.js


    【解决方案1】:

    也许将 AAD 应用注册中的重定向 URI 设置为新的服务器地址会有所帮助?

    也不确定您是否在演练中看到此“注释”,但它可能与此相关:“您需要在已注册的应用的身份验证选项卡中启用 ID 令牌选项。”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-02
      • 1970-01-01
      • 2016-08-30
      • 1970-01-01
      • 2018-03-01
      • 1970-01-01
      • 2021-09-05
      相关资源
      最近更新 更多