Repository navigation
Add a non-interactive device code login #7220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
29cdf1f
Add a non-interactive device code login
maksim-zuev-db 050d286
Share the device code approval instructions between both logins
maksim-zuev-db 6d41227
Test that completing a device code login checks the user code
maksim-zuev-db 0d86750
Delete the pending device code login after a successful login
maksim-zuev-db c72b1e1
Reject an empty --user-code or --confirmation-code
maksim-zuev-db 6e4eeff
Remove device code login tests that the retry test covers
maksim-zuev-db 48d9b99
Pass the context to NewDeviceCodeLogin in the non-interactive login
maksim-zuev-db f3ae208
Use require and assert in TestMemoryStore_PendingLoginUsesCopies
maksim-zuev-db 1af032a
Keep pending device code logins apart from the tokens
maksim-zuev-db ef2d021
Complete a device code login only with the settings that started it
maksim-zuev-db bda3307
Skip the workspace picker in the non-interactive device code login
maksim-zuev-db 5cc1763
Revert "Keep pending device code logins apart from the tokens"
maksim-zuev-db 71775ba
Revert "Skip the workspace picker in the non-interactive device code …
maksim-zuev-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
60 changes: 60 additions & 0 deletions
60
acceptance/cmd/auth/login/device-code/non-interactive/concurrent/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
|
|
||
| === A second login for the same profile replaces the first | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code | ||
|
|
||
| >>> update_file.py home/.databricks/token-cache.json WDJBMJHT NEWRCODE | ||
|
|
||
| >>> cache_keys | ||
| [ | ||
| "test#device-code" | ||
| ] | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: a newer login for profile test replaced this one. Complete the newer login with its user code. Run the same command without --user-code and --confirmation-code to start a new login | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code NEWR-CODE --confirmation-code FTFA-QQKY | ||
| Profile test was successfully saved | ||
|
|
||
| >>> print_requests.py --oneline //oidc/v1/token | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=FTFAQQKY&device_code=device-code-2&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} | ||
|
|
||
| === Logins for different targets are independent | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile a --use-device-code | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile b --use-device-code | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --use-device-code | ||
|
|
||
| >>> cache_keys | ||
| [ | ||
| "a#device-code", | ||
| "b#device-code", | ||
| "[DATABRICKS_URL]", | ||
| "[DATABRICKS_URL]#device-code", | ||
| "test" | ||
| ] | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile b --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Profile b was successfully saved | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile a --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Profile a was successfully saved | ||
|
|
||
| >>> cache_keys | ||
| [ | ||
| "a", | ||
| "b", | ||
| "[DATABRICKS_URL]", | ||
| "test" | ||
| ] | ||
|
|
||
| >>> print_requests.py --oneline //oidc/v1/token | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=FTFAQQKY&device_code=device-code-4&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=FTFAQQKY&device_code=device-code-5&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=FTFAQQKY&device_code=device-code-3&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} |
23 changes: 23 additions & 0 deletions
23
acceptance/cmd/auth/login/device-code/non-interactive/concurrent/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| sethome "./home" | ||
|
|
||
| # The real server issues a new user code for every login, while the fake server | ||
| # issues the same one. The script gives the second login its own user code. | ||
| title "A second login for the same profile replaces the first\n" | ||
| start_login LOG.first $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code | ||
| start_login LOG.second $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code | ||
| trace update_file.py home/.databricks/token-cache.json WDJBMJHT NEWRCODE | ||
| trace cache_keys | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| trace $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code NEWR-CODE --confirmation-code FTFA-QQKY | ||
| trace print_requests.py --oneline //oidc/v1/token | ||
|
|
||
| title "Logins for different targets are independent\n" | ||
| start_login LOG.a $CLI auth login --host $DATABRICKS_HOST --profile a --use-device-code | ||
| start_login LOG.b $CLI auth login --host $DATABRICKS_HOST --profile b --use-device-code | ||
| start_login LOG.host $CLI auth login --host $DATABRICKS_HOST --use-device-code | ||
| trace cache_keys | ||
| trace $CLI auth login --host $DATABRICKS_HOST --profile b --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| trace $CLI auth login --host $DATABRICKS_HOST --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| trace $CLI auth login --host $DATABRICKS_HOST --profile a --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| trace cache_keys | ||
| trace print_requests.py --oneline //oidc/v1/token | ||
4 changes: 4 additions & 0 deletions
4
acceptance/cmd/auth/login/device-code/non-interactive/errors/home/.databrickscfg.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [resources] | ||
| host = $DATABRICKS_HOST | ||
| resources = https://resource.test | ||
| auth_type = databricks-cli |
File renamed without changes.
98 changes: 98 additions & 0 deletions
98
acceptance/cmd/auth/login/device-code/non-interactive/errors/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
|
|
||
| === Device code login is disabled by default | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code | ||
| Error: --use-device-code is experimental. Set DATABRICKS_CLI_DEVICE_CODE=true to enable it | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: --use-device-code is experimental. Set DATABRICKS_CLI_DEVICE_CODE=true to enable it | ||
|
|
||
| === Flags the non-interactive login cannot honor | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --configure-cluster | ||
| Error: --configure-cluster is not supported by the non-interactive device code login. Set cluster_id on the profile after the login | ||
|
|
||
| === Missing host | ||
|
|
||
| >>> musterr [CLI] auth login --use-device-code | ||
| Error: --use-device-code requires a workspace host. Pass it as an argument or with --host | ||
|
|
||
| >>> musterr [CLI] auth login --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: --use-device-code requires a workspace host. Pass it as an argument or with --host | ||
|
|
||
| === Incomplete flags of the second step | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --confirmation-code FTFA-QQKY | ||
| Error: --confirmation-code requires --user-code | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT | ||
| Error: --user-code requires --confirmation-code | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: --confirmation-code requires --use-device-code | ||
|
|
||
| === Account host | ||
|
|
||
| >>> musterr [CLI] auth login --host https://accounts.cloud.databricks.test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Warn: [hostmetadata] failed to fetch host metadata for https://accounts.cloud.databricks.test, will skip for 1m0s | ||
| Error: --use-device-code is only supported for workspace hosts | ||
|
|
||
| === Profile scoped to resources | ||
|
|
||
| >>> musterr [CLI] auth login --profile resources --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: --use-device-code cannot be used with profile resources because its login is scoped to resources. Log in without --use-device-code | ||
|
|
||
| === No pending login | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: no pending device code login for profile test. Run the same command without --user-code and --confirmation-code to start a new login | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: no pending device code login for host [DATABRICKS_URL]. Run the same command without --user-code and --confirmation-code to start a new login | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code | ||
|
|
||
| === Wrong confirmation code | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code AAAA-AAAA | ||
| Error: token exchange: Invalid confirmation code (error code: invalid_request). Check the confirmation code and approve the login if you haven't, then rerun this command. Run the same command without --user-code and --confirmation-code to start a new login if it still fails | ||
|
|
||
| === Rerun with the right confirmation code | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code wdjb-mjht --confirmation-code ftfa-qqky | ||
| Profile test was successfully saved | ||
|
|
||
| === Rerun after the login was completed | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: no pending device code login for profile test. Run the same command without --user-code and --confirmation-code to start a new login | ||
|
|
||
| === Device code unknown to the server | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code | ||
|
|
||
| >>> update_file.py home/.databricks/token-cache.json device-code-2 unknown-device-code | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: token exchange: Invalid device code (error code: invalid_request). Run the same command without --user-code and --confirmation-code to start a new login | ||
|
|
||
| >>> cache_keys | ||
| [ | ||
| "[DATABRICKS_URL]", | ||
| "test" | ||
| ] | ||
|
|
||
| === Scopes changed between the steps | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --scopes sql | ||
|
|
||
| >>> musterr [CLI] auth login --host [DATABRICKS_URL] --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Error: the login for profile test was started with different scopes. Complete it with the same command that started it. Run the same command without --user-code and --confirmation-code to start a new login | ||
|
|
||
| >>> print_requests.py --oneline //oidc/v1/device/auth //oidc/v1/token | ||
| {"method": "POST", "path": "/oidc/v1/device/auth", "raw_body": "client_id=databricks-cli&scope=offline_access+all-apis"} | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=AAAAAAAA&device_code=device-code-1&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=FTFAQQKY&device_code=device-code-1&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} | ||
| {"method": "POST", "path": "/oidc/v1/device/auth", "raw_body": "client_id=databricks-cli&scope=offline_access+all-apis"} | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=FTFAQQKY&device_code=unknown-device-code&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} | ||
| {"method": "POST", "path": "/oidc/v1/device/auth", "raw_body": "client_id=databricks-cli&scope=offline_access+sql"} |
62 changes: 62 additions & 0 deletions
62
acceptance/cmd/auth/login/device-code/non-interactive/errors/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| sethome "./home" | ||
|
|
||
| title "Device code login is disabled by default\n" | ||
| ( | ||
| unset DATABRICKS_CLI_DEVICE_CODE | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| ) | ||
|
|
||
| title "Flags the non-interactive login cannot honor\n" | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --configure-cluster | ||
|
|
||
| # The non-interactive login cannot answer the profile picker or the host prompt. | ||
| title "Missing host\n" | ||
| trace musterr $CLI auth login --use-device-code | ||
| trace musterr $CLI auth login --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| title "Incomplete flags of the second step\n" | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --confirmation-code FTFA-QQKY | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| title "Account host\n" | ||
| trace musterr $CLI auth login --host https://accounts.cloud.databricks.test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| envsubst < "./home/.databrickscfg.tmpl" > "./home/.databrickscfg" | ||
|
|
||
| title "Profile scoped to resources\n" | ||
| trace musterr $CLI auth login --profile resources --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| title "No pending login\n" | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| start_login LOG.wrong-code $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code | ||
|
|
||
| title "Wrong confirmation code\n" | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code AAAA-AAAA | ||
|
|
||
| # A wrong confirmation code leaves the device code valid, so the pending | ||
| # login is kept. | ||
| title "Rerun with the right confirmation code\n" | ||
| trace $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code wdjb-mjht --confirmation-code ftfa-qqky | ||
|
|
||
| title "Rerun after the login was completed\n" | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| # The server discards the device code when the login expires. The pending | ||
| # login is then deleted. | ||
| title "Device code unknown to the server\n" | ||
| start_login LOG.expired $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code | ||
| trace update_file.py home/.databricks/token-cache.json device-code-2 unknown-device-code | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| trace cache_keys | ||
|
|
||
| # The token gets the scopes of the device authorization, so the second step | ||
| # cannot change them. | ||
| title "Scopes changed between the steps\n" | ||
| start_login LOG.scopes $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --scopes sql | ||
| trace musterr $CLI auth login --host $DATABRICKS_HOST --profile test --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| trace print_requests.py --oneline //oidc/v1/device/auth //oidc/v1/token |
5 changes: 5 additions & 0 deletions
5
acceptance/cmd/auth/login/device-code/non-interactive/flags/home/.databrickscfg.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [scoped] | ||
| host = $DATABRICKS_HOST | ||
| scopes = sql | ||
| client_id = databricks-cli | ||
| auth_type = databricks-cli |
15 changes: 15 additions & 0 deletions
15
acceptance/cmd/auth/login/device-code/non-interactive/flags/out.databrickscfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| [scoped] | ||
| host = [DATABRICKS_URL] | ||
| scopes = sql | ||
| auth_type = databricks-cli | ||
| workspace_id = [WORKSPACE_ID] | ||
| client_id = databricks-cli | ||
|
|
||
| [serverless] | ||
| host = [DATABRICKS_URL] | ||
| serverless_compute_id = auto | ||
| workspace_id = [WORKSPACE_ID] | ||
| auth_type = databricks-cli |
1 change: 1 addition & 0 deletions
1
acceptance/cmd/auth/login/device-code/non-interactive/flags/out.test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Cloud = false |
36 changes: 36 additions & 0 deletions
36
acceptance/cmd/auth/login/device-code/non-interactive/flags/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
|
|
||
| === Scopes and client ID from the profile | ||
|
|
||
| >>> [CLI] auth login --profile scoped --use-device-code | ||
| Using a browser on another device, visit: | ||
| [DATABRICKS_URL]/device/verification | ||
|
|
||
| And enter the code: | ||
| WDJB-MJHT | ||
|
|
||
| Once finished, complete the login by running the same command with | ||
| --user-code WDJB-MJHT and --confirmation-code set to the confirmation code | ||
| provided in your browser. | ||
|
|
||
| >>> [CLI] auth login --profile scoped --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Profile scoped was successfully saved | ||
|
|
||
| >>> print_requests.py --oneline //oidc/v1/device/auth //oidc/v1/token | ||
| {"method": "POST", "path": "/oidc/v1/device/auth", "raw_body": "client_id=databricks-cli&scope=offline_access+sql"} | ||
| {"method": "POST", "path": "/oidc/v1/token", "raw_body": "client_id=databricks-cli&confirmation_code=FTFAQQKY&device_code=device-code-1&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"} | ||
|
|
||
| === Serverless compute is configured in the second step | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile serverless --use-device-code --configure-serverless | ||
| Using a browser on another device, visit: | ||
| [DATABRICKS_URL]/device/verification | ||
|
|
||
| And enter the code: | ||
| WDJB-MJHT | ||
|
|
||
| Once finished, complete the login by running the same command with | ||
| --user-code WDJB-MJHT and --confirmation-code set to the confirmation code | ||
| provided in your browser. | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile serverless --use-device-code --configure-serverless --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| Profile serverless was successfully saved |
16 changes: 16 additions & 0 deletions
16
acceptance/cmd/auth/login/device-code/non-interactive/flags/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| sethome "./home" | ||
| envsubst < "./home/.databrickscfg.tmpl" > "./home/.databrickscfg" | ||
|
|
||
| # The rerun resolves the login from the same flags and profile as the first | ||
| # step, so the token exchange uses the client ID of the profile. | ||
| title "Scopes and client ID from the profile\n" | ||
| trace $CLI auth login --profile scoped --use-device-code | ||
| trace $CLI auth login --profile scoped --use-device-code --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
| trace print_requests.py --oneline //oidc/v1/device/auth //oidc/v1/token | ||
|
|
||
| # Only the second step saves the profile. | ||
| title "Serverless compute is configured in the second step\n" | ||
| trace $CLI auth login --host $DATABRICKS_HOST --profile serverless --use-device-code --configure-serverless | ||
| trace $CLI auth login --host $DATABRICKS_HOST --profile serverless --use-device-code --configure-serverless --user-code WDJB-MJHT --confirmation-code FTFA-QQKY | ||
|
|
||
| mv "./home/.databrickscfg" "./out.databrickscfg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
acceptance/cmd/auth/login/device-code/non-interactive/nominal/out.test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Cloud = false |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]The script rewritestoken-cache.jsonwithupdate_file.pybecause the fake server always issuesWDJBMJHT. The testing rules prefer modeling this inlibs/testserver/. For example, the fake could issue a new user code from a fixed sequence for each authorization, so the test exercises the replace behavior directly.