Skip to content

Commit f78303b

Browse files
Add --force-refresh flag to auth token command
Wire a new --force-refresh CLI flag that delegates to the SDK's ForceRefreshToken() method, bypassing the cached token validity check. The default path through Token() is unchanged. Note: this will not compile until the SDK ships ForceRefreshToken().
1 parent 9df759a commit f78303b

File tree

14 files changed

+184
-1
lines changed

14 files changed

+184
-1
lines changed

acceptance/cmd/auth/token/force-refresh-invalid-refresh-token/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Error: A new access token could not be retrieved because the refresh token is invalid. To reauthenticate, run the following command:
2+
$ databricks auth login --profile test-profile
3+
4+
Exit code: 1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export DATABRICKS_HOST_ORIG="$DATABRICKS_HOST"
2+
3+
sethome "./home"
4+
unset DATABRICKS_HOST
5+
unset DATABRICKS_TOKEN
6+
unset DATABRICKS_CONFIG_PROFILE
7+
8+
cat > "./home/.databrickscfg" <<ENDCFG
9+
[test-profile]
10+
host = $DATABRICKS_HOST_ORIG
11+
auth_type = databricks-cli
12+
ENDCFG
13+
14+
mkdir -p "./home/.databricks"
15+
cat > "./home/.databricks/token-cache.json" <<ENDCACHE
16+
{
17+
"version": 1,
18+
"tokens": {
19+
"test-profile": {
20+
"access_token": "cached-access-token",
21+
"token_type": "Bearer",
22+
"refresh_token": "test-refresh-token",
23+
"expiry": "2099-01-01T00:00:00Z"
24+
}
25+
}
26+
}
27+
ENDCACHE
28+
29+
errcode $CLI auth token --profile test-profile --force-refresh
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Ignore = [
2+
"home"
3+
]
4+
5+
[[Server]]
6+
Pattern = "POST /oidc/v1/token"
7+
Response.StatusCode = 401
8+
Response.Body = '{"error": "invalid_request", "error_description": "Refresh token is invalid"}'

acceptance/cmd/auth/token/force-refresh-no-cache/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Error: cache: databricks OAuth is not configured for this host. Try logging in again with `databricks auth login --profile test-profile` before retrying. If this fails, please report this issue to the Databricks CLI maintainers at https://github.com/databricks/cli/issues/new
2+
3+
Exit code: 1
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export DATABRICKS_HOST_ORIG="$DATABRICKS_HOST"
2+
3+
sethome "./home"
4+
unset DATABRICKS_HOST
5+
unset DATABRICKS_TOKEN
6+
unset DATABRICKS_CONFIG_PROFILE
7+
8+
cat > "./home/.databrickscfg" <<ENDCFG
9+
[test-profile]
10+
host = $DATABRICKS_HOST_ORIG
11+
auth_type = databricks-cli
12+
ENDCFG
13+
14+
errcode $CLI auth token --profile test-profile --force-refresh
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ignore = [
2+
"home"
3+
]

acceptance/cmd/auth/token/force-refresh-success/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"oauth-token"

0 commit comments

Comments
 (0)