Skip to content

Commit 89b5458

Browse files
committed
Built site for brickster@0.2.13.9000: eba3486
1 parent 2caf5db commit 89b5458

12 files changed

Lines changed: 227 additions & 74 deletions

dev/articles/setup-auth.html

Lines changed: 94 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/articles/setup-auth.md

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ The [brickster](https://github.com/databrickslabs/brickster) package
66
connects to a Databricks workspace in three ways:
77

88
1. [OAuth user-to-machine (U2M)
9-
authentication](https://docs.databricks.com/en/dev-tools/auth/oauth-u2m.html#oauth-user-to-machine-u2m-authentication)
9+
authentication](https://docs.databricks.com/en/dev-tools/auth/oauth-u2m.html#oauth-user-to-machine-u2m-authentication),
10+
either directly or through credentials managed by the Databricks CLI
1011
2. [OAuth machine-to-machine (M2M)
1112
authentication](https://docs.databricks.com/en/dev-tools/auth/oauth-m2m.html)
1213
3. [Personal Access Tokens
@@ -56,9 +57,6 @@ To get started add the following to your `.Renviron`:
5657
- `ARM_TENANT_ID`: Azure AD tenant id (*only required for Azure service
5758
principal OAuth M2M*)
5859

59-
- `DATABRICKS_AUTH_TYPE`: Optional auth mode override (`oauth-m2m`,
60-
`azure-client-secret`, `oauth-u2m`)
61-
6260
- `DATABRICKS_WSID`: The workspace ID
6361
([docs](https://docs.databricks.com/workspace/workspace-details.html#workspace-instance-names-urls-and-ids))
6462

@@ -85,12 +83,12 @@ For Azure service principal OAuth M2M:
8583
ARM_CLIENT_SECRET=abcdefg1234567890
8684
ARM_TENANT_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
8785

88-
With no explicit auth override,
86+
With no `auth_type` in a selected `.databrickscfg` profile,
8987
[brickster](https://github.com/databrickslabs/brickster) attempts
9088
Databricks OAuth M2M (`DATABRICKS_CLIENT_*`), then Azure service
91-
principal OAuth M2M (`ARM_*`), then OAuth U2M. Set
92-
`DATABRICKS_AUTH_TYPE=azure-client-secret` to force Azure service
93-
principal authentication.
89+
principal OAuth M2M (`ARM_*`), then OAuth U2M. When using
90+
`.databrickscfg`, set `auth_type = azure-client-secret` in the profile
91+
to force Azure service principal authentication.
9492

9593
**Note**: Recommend creating an `.Renviron` for each project. You can
9694
create `.Renviron` within your user home directory if required.
@@ -145,29 +143,47 @@ simplify switching of credentials within an R project/session:
145143
2. Using a `.databrickscfg` file (primary method in [Databricks
146144
CLI](https://docs.databricks.com/dev-tools/cli/index.html#set-up-authentication))
147145

148-
To differentiate between (1) and (2) the option `use_databrickscfg` is
149-
used, the following example shows how to switch the session to use
150-
`.databrickscfg`.
146+
The `use_databrickscfg` option selects which configuration source
147+
[brickster](https://github.com/databrickslabs/brickster) reads. It does
148+
not sign in to the Databricks CLI or select a named profile. The
149+
following example switches the session from `.Renviron` to
150+
`.databrickscfg`:
151151

152152
``` r
153153

154-
# will use the `DEFAULT` profile in `.databrickscfg`
154+
# uses the CLI-selected default profile, or `DEFAULT` when none is selected
155155
options(use_databrickscfg = TRUE)
156156

157-
# values returned should be those in profile of `.databrickscfg`
157+
# values are read from `.databrickscfg`
158158
db_host()
159159
db_token()
160160
```
161161

162-
The default behaviour is to read credentials from `.Renviron`. If you
163-
wish to change this it’s recommended to set the option within
164-
`.Rprofile` so that it’s set during initialization of the R session.
162+
With its default value of `FALSE`,
163+
[brickster](https://github.com/databrickslabs/brickster) does not
164+
discover profiles created by `databricks auth login` and does not enable
165+
the `databricks-cli` authentication provider. Set the option in
166+
`.Rprofile` when `.databrickscfg` should be the normal configuration
167+
source. Posit Workbench managed OAuth sessions enable `.databrickscfg`
168+
automatically.
165169

166170
### Switching Between Credentials
167171

168-
The `db_profile` option controls which profiles credentials are returned
169-
by
170-
[`db_host()`](https://databrickslabs.github.io/brickster/dev/reference/db_host.md)/[`db_token()`](https://databrickslabs.github.io/brickster/dev/reference/db_token.md)/[`db_wsid()`](https://databrickslabs.github.io/brickster/dev/reference/db_wsid.md).
172+
When `.databrickscfg` is enabled, the selected profile controls the
173+
host, credentials, authentication type, and the profile passed to
174+
`databricks auth token`.
175+
[brickster](https://github.com/databrickslabs/brickster) resolves the
176+
profile in this order:
177+
178+
1. `DATABRICKS_CONFIG_PROFILE`
179+
2. The `db_profile` option
180+
3. The CLI default selected by `databricks auth switch`
181+
4. The `DEFAULT` profile
182+
183+
`DATABRICKS_CONFIG_PROFILE` is the standard Databricks unified
184+
authentication setting. `db_profile` is the
185+
[brickster](https://github.com/databrickslabs/brickster) session-level
186+
equivalent.
171187

172188
Profiles enable you to switch contexts between:
173189

@@ -181,20 +197,20 @@ This behaviour works when using credentials specified in either
181197
``` r
182198

183199
# using .Renviron
184-
db_host() # returns `DB_HOST` (.Renviron)
200+
db_host() # returns `DATABRICKS_HOST` (.Renviron)
185201

186202
# switch profile to 'prod'
187203
options(db_profile = "prod")
188-
db_host() # returns `DB_HOST_PROD` (.Renviron)
204+
db_host() # returns `DATABRICKS_HOST_PROD` (.Renviron)
189205

190-
# set back to default (NULL)
206+
# clear the session-specific profile selection
191207
options(db_profile = NULL)
192-
# use .databrickcfg
208+
# use .databrickscfg
193209
options(use_databrickscfg = TRUE)
194-
db_host() # returns host from `DEFAULT` profile (.databrickscfg)
210+
db_host() # returns the CLI-selected default, otherwise `DEFAULT` (.databrickscfg)
195211

196212
options(db_profile = "prod")
197-
db_host() # returns host from `prod` profile in (.datarickscfg)
213+
db_host() # returns host from `prod` profile (.databrickscfg)
198214
```
199215

200216
It is expected that profiles in `.Renviron` will adhere to the same
@@ -226,16 +242,71 @@ There is only one
226242
[brickster](https://github.com/databrickslabs/brickster) specific
227243
feature and it is the inclusion of `wsid` alongside `host`/`token`.
228244

229-
When using OAuth M2M with a `.databrickscfg` profile:
245+
Supported OAuth fields in a `.databrickscfg` profile include:
230246

231247
- Databricks service principal fields: `client_id`, `client_secret`
232248
- Azure service principal fields: `azure_client_id`,
233249
`azure_client_secret`, `azure_tenant_id`
234250
- Optional auth mode override: `auth_type` (`oauth-m2m`,
235-
`azure-client-secret`, `oauth-u2m`)
251+
`azure-client-secret`, `oauth-u2m`, `databricks-cli`)
252+
253+
#### Databricks CLI OAuth profiles
254+
255+
Profiles created by `databricks auth login` use
256+
`auth_type = databricks-cli`. The login can be performed from any
257+
terminal; the credentials are not scoped to that terminal session.
258+
[brickster](https://github.com/databrickslabs/brickster) must run as the
259+
same operating-system user and use the same `.databrickscfg` and CLI
260+
credential storage.
261+
262+
The `databricks-cli` provider is intentionally available only when the
263+
selected `.databrickscfg` profile contains `auth_type = databricks-cli`.
264+
Environment configuration cannot activate this provider independently.
265+
266+
Enable `.databrickscfg` and select the profile before making requests:
267+
268+
``` r
269+
270+
options(
271+
use_databrickscfg = TRUE,
272+
db_profile = "e2-demo"
273+
)
274+
275+
# The host and CLI token are resolved from the same profile.
276+
db_sql_warehouse_list()
277+
```
278+
279+
Instead of `db_profile`, set `DATABRICKS_CONFIG_PROFILE`, or select the
280+
CLI default outside R:
281+
282+
``` sh
283+
databricks auth switch --profile e2-demo
284+
```
236285

237-
If both `DATABRICKS_AUTH_TYPE` (environment variable) and `auth_type`
238-
(`.databrickscfg`) are set, `DATABRICKS_AUTH_TYPE` takes precedence.
286+
When a profile is selected,
287+
[brickster](https://github.com/databrickslabs/brickster) calls
288+
`databricks auth token --profile <profile>`. Without a selected profile,
289+
[brickster](https://github.com/databrickslabs/brickster) follows the
290+
Databricks SDK behavior and asks the CLI for the resolved host. If
291+
multiple profiles contain the same host, the CLI refuses to guess;
292+
select a profile rather than signing in again. Avoid supplying a
293+
different `host` argument while a profile is selected, because the
294+
request host and CLI credential would no longer describe the same
295+
configuration.
296+
297+
Token acquisition is deferred until an API request is performed.
298+
[brickster](https://github.com/databrickslabs/brickster) keeps only the
299+
short-lived access token in memory until it expires, then calls the CLI
300+
again. The Databricks CLI remains responsible for durable credential
301+
storage and refresh. The CLI must be available on `PATH`, or its
302+
executable can be provided with `DATABRICKS_CLI_PATH`.
303+
`DATABRICKS_CONFIG_FILE` is inherited by the CLI when using a
304+
non-default config location.
305+
306+
The `oauth-u2m` mode remains
307+
[brickster](https://github.com/databrickslabs/brickster)’s direct
308+
browser-based OAuth flow; it does not reuse credentials created by
309+
`databricks auth login`.
239310

240311
`wsid` is used by the connections pane integration in RStudio as the
241312
underlying API’s require it.

dev/news/index.html

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/news/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66
workspaces in one R session by isolating OAuth clients and cached
77
tokens per workspace
88
([\#255](https://github.com/databrickslabs/brickster/issues/255))
9+
- OAuth tokens are now refreshed 40 seconds before expiry, avoiding
10+
Databricks API rejections during the final 30 seconds of a token’s
11+
lifetime; this requires [httr2](https://httr2.r-lib.org) 1.3.0 or
12+
later
13+
([\#257](https://github.com/databrickslabs/brickster/issues/257))
14+
- Added `databricks-cli` authentication support for profiles created by
15+
`databricks auth login`;
16+
[brickster](https://github.com/databrickslabs/brickster) obtains
17+
tokens through `databricks auth token`, caches only the short-lived
18+
access token in memory, and leaves durable credentials and refresh to
19+
the CLI
20+
([\#253](https://github.com/databrickslabs/brickster/issues/253))
21+
- Authentication mode overrides now come from `auth_type` in the
22+
selected `.databrickscfg` profile; replace `DATABRICKS_AUTH_TYPE` with
23+
the profile field. Environment-only authentication continues to infer
24+
the mode from available credentials.
925
- Fixed
1026
[`dbWriteTable()`](https://dbi.r-dbi.org/reference/dbWriteTable.html)
1127
and

dev/pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ articles:
88
setup-auth: setup-auth.html
99
sql-backend: sql-backend.html
1010
working-with-volumes: working-with-volumes.html
11-
last_built: 2026-07-11T01:02Z
11+
last_built: 2026-07-16T00:31Z
1212
urls:
1313
reference: https://databrickslabs.github.io/brickster/reference
1414
article: https://databrickslabs.github.io/brickster/articles

dev/reference/db_oauth_client.html

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/reference/db_oauth_client.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ db_oauth_client(
4545

4646
- auth_type:
4747

48-
Optional explicit auth mode override from `DATABRICKS_AUTH_TYPE`.
48+
Optional auth mode. Defaults to `auth_type` from the selected
49+
`.databrickscfg` profile.
4950

5051
## Value
5152

dev/reference/default_config_profile.html

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/reference/default_config_profile.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ profile name
1414

1515
## Details
1616

17-
Returns the config profile first looking at `DATABRICKS_CONFIG_PROFILE`
18-
and then the `db_profile` option.
17+
Returns the config profile first looking at `DATABRICKS_CONFIG_PROFILE`,
18+
then the `db_profile` option, and then the CLI-selected default profile.

dev/reference/read_env_var.html

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)