Skip to content

Commit

Permalink
Handle az CLI token refresh (#820)
Browse files Browse the repository at this point in the history
## Changes
Handle az CLI token refresh
  • Loading branch information
fjakobs authored Jul 28, 2023
1 parent ae67ba2 commit bfea2ec
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/databricks-vscode/src/configuration/auth/AzureCliCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export class AzureCliCheck implements Disposable {
type: "next",
next: "loginAzureCli",
};
} else if (result.expired) {
return {
type: "next",
next: "loginAzureCli",
};
} else if (result.aud) {
this.azureLoginAppId = result.aud;
return {
Expand Down Expand Up @@ -164,6 +169,7 @@ export class AzureCliCheck implements Disposable {
iss?: string;
aud?: string;
canLogin: boolean;
expired: boolean;
error?: Error;
}> {
const workspaceClient = new WorkspaceClient(
Expand All @@ -188,6 +194,18 @@ export class AzureCliCheck implements Disposable {
return {
iss: m[1],
canLogin: false,
expired: false,
};
}

m = e.message.match(
/(Interactive authentication is needed). Please run:\naz login( --scope ([a-z0-9-]+?)\/\.default)?\n/s
);
if (m) {
return {
canLogin: false,
error: new Error(m[1]),
expired: true,
};
}

Expand All @@ -198,12 +216,13 @@ export class AzureCliCheck implements Disposable {
return {
aud: m[1],
canLogin: false,
expired: false,
};
}

return {canLogin: false, error: e};
return {canLogin: false, error: e, expired: false};
}
return {canLogin: true};
return {canLogin: true, expired: false};
}

// check if Azure CLI is installed
Expand Down

0 comments on commit bfea2ec

Please sign in to comment.