Best way to handle msal redirect errors from the Msal2Provider in an angular project?

Published

i am using the @microsoft/mgt libraries in order to use the Msal2Provider, people picker, and teams channel picker features. Everything is going great but I would like for our app to not crash if there ever is an error signing in to microsoft to retrieve the MSAL token using:

   Providers.globalProvider = new Msal2Provider({
      clientId: 'my-client-id',
      scopes: [`my-scopes`],
      authority: 'my-authority',
      redirectUri: '/',
      loginType: LoginType.Redirect
    });
    const msalProvider = Providers.globalProvider;
    msalProvider.login()

There is only a small part of or app that needs the mgt-toolkit components so it would be a waste if the app cannot start at all if the login to microsoft fails.

I was hoping for something like:

msalProvider.onAuthorizationError((): void => this.myHandleErrorFunction());

or something similar to how we can hook into the provider’s state changes

Source: Angular Questions

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq