Error: Uninitialized_public_client_application in angular after version 16 upgrade

638 views Asked by At

after upgrading to angular 16 from 15, new updates did not support msal v2 so updated it to the latest version i.e. v3, now getting below error in browser:

Error: uncaught (in promise): BrowserAuthError: uninitialized_public_client_application: you must call and await the initialize function before attempting to call any other MSAL API.

Can anyone suggest something please

I read documentation for migrating from msal 2 to 3, but adding those snippet to my application created more issues

1

There are 1 answers

0
Sunny On

I was having this issue as well after the upgrade.

Make sure that you initialize MSAL before making any authentication-related calls. Ensure that this initialization is completed before any other MSAL API calls.

import { MsalService } from '@azure/msal-angular';

constructor(private authService: MsalService) {
  this.authService.initialize();
}