Touch up MSAL errors (#22906)

This commit is contained in:
Cheena Malhotra
2023-04-28 21:22:26 -07:00
committed by GitHub
parent ed8149599c
commit e26937b101
2 changed files with 4 additions and 4 deletions

View File

@@ -327,7 +327,7 @@ export abstract class AzureAuth implements vscode.Disposable {
if (!resource) {
Logger.error(`Unable to find Azure resource ${azureResource}`);
return null;
throw new Error(localize('msal.resourceNotFoundError', `Unable to find configuration for Azure Resource {0}`, azureResource));
}
// Resource endpoint must end with '/' to form a valid scope for MSAL token request.
@@ -336,7 +336,7 @@ export abstract class AzureAuth implements vscode.Disposable {
let account: AccountInfo | null = await this.getAccountFromMsalCache(accountId);
if (!account) {
Logger.error('Error: Could not fetch account when acquiring token');
return null;
throw new Error(localize('msal.accountNotFoundError', `Unable to find account info when acquiring token.`));
}
let newScope;
if (resource.azureResourceId === azdata.AzureResource.ResourceManagement) {
@@ -735,7 +735,7 @@ export abstract class AzureAuth implements vscode.Disposable {
response = await result.action(tenant.id);
}
return response;
return result?.booleanResult || response;
}
//#endregion

View File

@@ -182,7 +182,7 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp
}
return token;
} else {
Logger.error(`MSAL: getToken call failed`);
Logger.error(`MSAL: getToken call failed: ${authResult}`);
// Throw error with MSAL-specific code/message, else throw generic error message
if (this.isProviderError(authResult)) {
throw new Error(localize('msalTokenError', `{0} occurred when acquiring token. \n{1}`, authResult.errorCode, authResult.errorMessage));