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 {
      logger.info("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":
            logger.warning(
              `InteractiveBrowserCredential: authentication returned errorCode ${err.errorCode}`
            );
            break;
          default:
            logger.warning(`InteractiveBrowserCredential: failed to acquire token: ${err}`);
            throw err;
        }
      }
    }

    let authPromise: Promise | undefined;