Skip to content

Commit

Permalink
Add more debug console logs so we can assist users better
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Omidi committed Apr 8, 2020
1 parent fca2344 commit 2046d65
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions extensions/azurecore/src/account-provider/auths/azureAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,15 @@ 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;
}

const resource = this.resources.find(s => s.azureResourceId === azureResource);
if (!resource) {
return undefined;
}

const azureAccount = account as AzureAccount;
const response: TokenResponse = {};

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 2046d65

Please sign in to comment.