infodev
infodev

Reputation: 5245

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 ?

Upvotes: 0

Views: 643

Answers (1)

Heiko Polenz
Heiko Polenz

Reputation: 11

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

Upvotes: 1

Related Questions