【问题标题】:How to authenticate Angularjs application using Azure Active Directory Authentication Library?如何使用 Azure Active Directory 身份验证库对 Angularjs 应用程序进行身份验证?
【发布时间】:2019-09-14 16:45:03
【问题描述】:

我有一个带有 AngularJS 前端和 spring REST 后端的 Web 应用程序。我必须使用 Azure AD 进行身份验证。在登录页面,当我输入凭据时,它会将我带到 Azure 并要求我输入凭据,然后我收到消息:

AADSTS50011:请求中指定的回复 url 与为应用程序配置的回复 url 不匹配:'xxxx-xxx-xxxx-xxxx-xxxx'。

发出请求的页面表单是:

https://xxx.xxxx.com/App/#/login

而在 Azure 中为该应用程序指定的 replyUrl 是:

https://xxx.xxxx.com/App/#/

我是否必须使两个网址相同,即https://xxx.xxxx.com/App/#/login

我对 ADAL 的初始化代码是:

adalProvider.init({
        instance: 'https://login.microsoftonline.com/', 
        tenant: 'xxxxxxxx.onmicrosoft.com',
        clientId: 'xxxxxxxxxxxxxxxxxxxxx',
        popUp: false,

    },
    $httpProvider
    );  

即使将replyTo url 与发出请求的页面的url 相同,我仍然得到相同的错误。

【问题讨论】:

    标签: angularjs azure azure-active-directory


    【解决方案1】:

    我是否必须使两个网址相同,即https://xxx.xxxx.com/App/#/login

    简而言之:是的。

    a lot of information to be found about this error online

    InvalidReplyTo - 回复地址缺失、配置错误或与为应用配置的回复地址不匹配。作为解决方案,请确保将此缺少的回复地址添加到 Azure Active Directory 应用程序,或者让有权在 Active Directory 中管理您的应用程序的人为您执行此操作。

    取自Authentication and authorization error codes

    【讨论】:

    • 感谢您的及时回复。现在网址完全相同:localhost:8080/AppV1.1.2/#/login,仍然收到相同的消息。
    • 确定吗?它需要完全相同,包括版本和端口号。如果是,它应该可以工作。