diff --git a/extensions/azurecore/src/account-provider/auths/azureAuth.ts b/extensions/azurecore/src/account-provider/auths/azureAuth.ts index cc5e6b515713..9039c0125485 100644 --- a/extensions/azurecore/src/account-provider/auths/azureAuth.ts +++ b/extensions/azurecore/src/account-provider/auths/azureAuth.ts @@ -176,6 +176,7 @@ export abstract class AzureAuth implements vscode.Disposable { public async getSecurityToken(account: azdata.Account, azureResource: azdata.AzureResource): Promise { if (account.isStale === true) { + console.log('Account was stale, no tokens being fetched'); return undefined; } @@ -183,6 +184,7 @@ export abstract class AzureAuth implements vscode.Disposable { if (!resource) { return undefined; } + const azureAccount = account as AzureAccount; const response: TokenResponse = {}; @@ -213,17 +215,21 @@ export abstract class AzureAuth implements vscode.Disposable { const baseToken = await this.getCachedToken(account.key); if (!baseToken) { + account.isStale = true; + console.log('Base token was empty, account is stale.'); return undefined; } try { await this.refreshAccessToken(account.key, baseToken.refreshToken, tenant, resource); } catch (ex) { + console.log(ex); account.isStale = true; return undefined; } cachedTokens = await this.getCachedToken(account.key, resource.id, tenant.id); if (!cachedTokens) { + console.log('Refresh access tokens didn not set cache'); return undefined; } } @@ -326,6 +332,10 @@ export abstract class AzureAuth implements vscode.Disposable { } const allSubs: Subscription[] = []; const tokens = await this.getSecurityToken(account, azdata.AzureResource.ResourceManagement); + if (!tokens) { + console.log('There were no resource management tokens to retrieve subscriptions from. Account is stale.'); + account.isStale = true; + } for (const tenant of account.properties.tenants) { const token = tokens[tenant.id];