简体   繁体   中英

Authentification to Azure Ad in Angular using Msal

I would authentificate to Azure AD .

I have Configured my app in 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:

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 ). 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 ?

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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