簡體   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