Add more debug console logs so we can assist users better (#9907)

This commit is contained in:
Amir Omidi
2020-04-08 13:12:26 -07:00
committed by GitHub
parent 8e164973ee
commit 21964e15b0

View File

@@ -176,6 +176,7 @@ export abstract class AzureAuth implements vscode.Disposable {
public async getSecurityToken(account: azdata.Account, azureResource: azdata.AzureResource): Promise<TokenResponse | undefined> {
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];