繁体   English   中英

使用Msal对Angular中的Azure广告进行身份验证

[英]Authentification to Azure Ad in Angular using Msal

我将对Azure AD进行身份验证。

我已经在module.app配置了我的应用程序

MsalModule.forRoot({
  clientID: "ClientId",
  authority: "https://login.microsoftonline.com/tenant.onmicrosoft.com/",
  redirectUri: "http://localhost:4200/",
  validateAuthority : true,
  cacheLocation : "localStorage",
  postLogoutRedirectUri: "http://localhost:4200/",
  navigateToLoginRequestUrl : true,
  popUp: true,
  consentScopes: ["user.read", "api://??what_Id_Sould_I_Put???/access_as_user"],
  unprotectedResources: ["https://angularjs.org/"],
  correlationId: '1234',
  piiLoggingEnabled: true,
}),

在我的组件中,我使用loginPopup方法进行连接:

this.authService.loginPopup(["user.read" ,"api://ClientId/access_as_user"]);

我得到这个错误

AADSTS50001:在名为de5e3c28-141c-4d3e-90ea-aa3326abe67d(奇怪的ID)的租户中找不到名为api:// ClientId的应用程序。 如果租户的管理员未安装该应用程序,或者该租户中的任何用户未同意该应用程序,则可能会发生这种情况。 您可能已将身份验证请求发送给错误的租户。

示例演示中, ConsentScope变量中使用的ID客户端ID不同,我不知道该ID是什么以及如何获取它?

只需删除行

consentScopes: ["user.read", "api://??what_Id_Sould_I_Put???/access_as_user"],

从配置。 并换线

this.authService.loginPopup(["user.read" ,"api://ClientId/access_as_user"]);

this.authService.loginPopup();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM