Microsoft App注册,身份验证和重定向URL

时间:2019-02-21 23:44:45

标签: javascript angular microsoft-graph msal

将Angular 2+与@azure/msal-angular库一起使用。

我有一个具有域的应用

  

http://localhost:4200/userId/someOtherId

因此它可以是任何

  

http://localhost:4200/2425/2532152

     

http://localhost:4200/35235/152115

我有一个按钮,用Microsoft登录。点击该按钮后,我会调用登录方法

import { MsalService } from '@azure/msal-angular';

/// more code
signIn() {
    await this.msalService.loginPopup(environment.microsoft.scopes);
    //more code
}

(请参见此处的登录方法:https://docs.microsoft.com/en-us/graph/tutorials/angular?tutorial-step=3,我也做同样的事情)

现在,在应用程序注册门户中,我有 http://localhost:4200作为我的重定向URI。

结果,当我尝试进行身份验证时,出现以下错误:

  

请求中指定的回复URL与回复URL不匹配   为应用程序配置

我的问题是,我该如何解决这个问题?有人说我应该传递状态&state = userId:someotherId,但是如何使用microsoft's authentication library for angular来做到这一点?

1 个答案:

答案 0 :(得分:1)

UserAgentApplication接受状态作为构造函数中options对象的属性。

但是,当他们创建从UserAgentApplication派生的MSAL-Service时,看起来好像他们没有公开state参数。我建议在GitHub存储库上打开一个问题。