diff --git a/sdk/identity/identity/src/msal/utils.ts b/sdk/identity/identity/src/msal/utils.ts index ff2787caacdc..55d6df133f3e 100644 --- a/sdk/identity/identity/src/msal/utils.ts +++ b/sdk/identity/identity/src/msal/utils.ts @@ -149,8 +149,13 @@ export class MsalBaseUtilities { * Handles MSAL errors. */ protected handleError(scopes: string[], error: Error, getTokenOptions?: GetTokenOptions): Error { - if (error instanceof msalCommon.AuthError) { - switch (error.errorCode) { + if ( + error.name === "AuthError" || + error.name === "ClientAuthError" || + error.name === "BrowserAuthError" + ) { + const msalError = error as msalCommon.AuthError; + switch (msalError.errorCode) { case "endpoints_resolution_error": this.logger.info(formatError(scopes, error.message)); return new CredentialUnavailable(error.message); @@ -158,7 +163,7 @@ export class MsalBaseUtilities { case "interaction_required": case "login_required": this.logger.info( - formatError(scopes, `Authentication returned errorCode ${error.errorCode}`) + formatError(scopes, `Authentication returned errorCode ${msalError.errorCode}`) ); break; default: @@ -166,10 +171,11 @@ export class MsalBaseUtilities { break; } } - if (error instanceof msalCommon.ClientConfigurationError) { - return error; - } - if (error.name === "AbortError") { + if ( + error.name === "ClientConfigurationError" || + error.name === "BrowserConfigurationAuthError" || + error.name === "AbortError" + ) { return error; } return new AuthenticationRequired(scopes, getTokenOptions, error.message);