I am building an Angular 8 app that authenticates the user against Microsoft Azure Active Directory using adal-angular4. I have an ASP.NET Core API set up and associated with a client app on Azure.
I have followed the following documentation to set up Active Directory: -
and the following for setting up my Angular app and my .NET Core API using adal-angular4: -
https://www.digital-moves.eu/2018/07/19/authentication-with-azure-ad-angular-6-client-web-api/
The redirect URL appears to work, in that the correct callback component in my application is hit. However, at this point the app gets into an endless loop of re-attempting the login and redirecting. Eventually the login attempt produces the exception 'we couldn’t sign you in. Please try again', presumably due to being locked out.
In my app.module.ts: -
providers: [
AdalService, { provide: HTTP_INTERCEPTORS, useClass: AdalInterceptor, multi: true },
RefreshTokenService
My adal config file: -
private adalConfig = {
tenant: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
redirectUri: 'http://localhost:4200/auth-callback',
postLogoutRedirectUri: "http://localhost:4200/end-session",
endpoints: { "https://visionapi2019.azurewebsites.net": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" },
cacheLocation: 'localStorage'
};
constructor(private adal: AdalService){
this.adal.init(this.adalConfig);
}
ngOnInit() {
this.adal.login();
}
In my callback component I have the following: -
ngOnInit() {
this.adal.handleWindowCallback();
this.router.navigate(['test-api']);
}
Navigation to component 'test-api' works, but then the infinite loop begins.
Thanks!