How to use the msal.AuthError function in msal

To help you get started, we’ve selected a few msal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / identity / identity / src / credentials / interactiveBrowserCredential.browser.ts View on Github external
private async acquireToken(
    authParams: msal.AuthenticationParameters
  ): Promise {
    let authResponse: msal.AuthResponse | undefined;
    try {"InteractiveBrowserCredential: attempting to acquire token silently");
      authResponse = await this.msalObject.acquireTokenSilent(authParams);
    } catch (err) {
      if (err instanceof msal.AuthError) {
        switch (err.errorCode) {
          case "consent_required":
          case "interaction_required":
          case "login_required":
              `InteractiveBrowserCredential: authentication returned errorCode ${err.errorCode}`
            logger.warning(`InteractiveBrowserCredential: failed to acquire token: ${err}`);
            throw err;

    let authPromise: Promise | undefined;