简体   繁体   English

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

[英]Authentification to Azure Ad in Angular using Msal

I would authentificate to Azure AD . 我将对Azure AD进行身份验证。

I have Configured my app in module.app 我已经在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,
}),

I my component I use loginPopup method for connexion: 在我的组件中,我使用loginPopup方法进行连接:

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

I get this error 我得到这个错误

AADSTS50001: The application named api://ClientId was not found in the tenant named de5e3c28-141c-4d3e-90ea-aa3326abe67d (Strange ID ). AADSTS50001:在名为de5e3c28-141c-4d3e-90ea-aa3326abe67d(奇怪的ID)的租户中找不到名为api:// ClientId的应用程序。 This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. 如果租户的管理员未安装该应用程序,或者该租户中的任何用户未同意该应用程序,则可能会发生这种情况。 You might have sent your authentication request to the wrong tenant. 您可能已将身份验证请求发送给错误的租户。

In the sample demo the ID used in ConsentScope variable is different than the Client ID , I don't know what is that ID and how to get it ? 示例演示中, ConsentScope变量中使用的ID客户端ID不同,我不知道该ID是什么以及如何获取它?

Just remove the line 只需删除行

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

from the config. 从配置。 And change the line 并换线

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

to

this.authService.loginPopup();

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

相关问题 Angular 路由与 Msal Azure AD 集成 - Angular routing with Msal Azure AD integration 使用Azure AD B2C时向Angular SPA和MSAL添加角色 - Adding roles to Angular SPA and MSAL when using using Azure AD B2C 使用@azure-msal-angular 进行 Microsoft AD 身份验证时出现 performanceMeasurement.startMeasurement 错误 - performanceMeasurement.startMeasurement error when using @azure-msal-angular for Microsoft AD authentication redirect_uri_mismatch Azure AD B2C,角度使用MSAL - redirect_uri_mismatch Azure AD B2C with angular using MSAL 带有 Azure AD (MSAL) 的赛普拉斯 - Cypress with Azure AD (MSAL) 在角度应用程序中添加 Azure AD 身份验证(使用 MSAL)时出现 CORS 问题 - Trouble with CORS when adding Azure AD authentication (with MSAL) in a angular app CORS 问题 Angular MSAL Azure AD Do.net Core Web API - CORS Issue with Angular MSAL Azure AD Dotnet Core Web API 使用 MSAL Angular 包装器在 Ionic 4 中处理来自 Azure AD 的回调 - Handling callback from Azure AD in Ionic 4 with MSAL Angular wrapper Azure AD angular MSAL 库请求的用户访问令牌和 WEB_ZDB9742387_14CA8DE634A7CEdjango10838DE634A7CEDjango1 验证 - Azure AD User access token requested by angular MSAL library and validation by WEB API using django_auth_adfs 通过 angular 8 中的@azure/msal-angular 库获取 azure 广告用户组 - Get azure ad user group by @azure/msal-angular library in angular 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM