Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions sdk/identity/identity/src/msal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,33 @@ 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);
case "consent_required":
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:
this.logger.info(formatError(scopes, `Failed to acquire token: ${error.message}`));
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);
Expand Down