@microsoft/mgt and mgt-msal2-provider compatibility with @Angular@16

324 Views Asked by At

Im' trying to upgrade my App to @Angular@16,so i had to upgrades Msal Packages too. @azure/msal-angular@3 and @azure/msal-browser@3.

The Point is that @microsoft/mgt-msal2-provider is still using @azure/msal-browser": "^2.22.0 and then is incompatible.

the PublicClientApplication is not compatible anymore as global provider

constructor(
    @Inject(MSAL_INSTANCE) public publicClientApplication: PublicClientApplication
  ) {

    Providers.globalProvider = new Msal2Provider({
      publicClientApplication: this.publicClientApplication
    });

}

Is there a way to fix this.

I Tried to overrides the version with

"dependencies": {
    "@microsoft/mgt": "^3.1.1",
    "@microsoft/mgt-msal2-provider": "^3.1.1",
    "@azure/msal-angular": "^3.0.2",
    "@azure/msal-browser": "^3.0.2",
},
  "overrides" : {
    "@microsoft/mgt-msal2-provider": {
      "@azure/msal-browser": "^3.0.2"
    }
  },

the error disapear but none of the mgt components are displayed anymore.

1

There are 1 best solutions below

0
GavinB On

I'm maintainer of the Microsoft MGT packages.

We're evaluating how we should approach providing support for MSAL v3. The MSAL v3 PublicClientApplication now requires that there is an awaited call to the initialize method before attempting to sign in a user.

You can refactor your code to do this, or when our next version is released we'll have code inside the Msal2Povider class to do this. I've done a little testing in working on https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/2673 and I didn't have any problems when the PublicClientApplication instance was a v3 instead of a v2 instance.

If you want to try our the next version before we ship it's on npm as version 3.1.2-preview.b9fcfe7. Please do raise an issue on the repo if you encounter more problems.