Skip to content

Persist token acquired through 'external-browser' auth type#110

Merged
nfx merged 1 commit intomainfrom
external-browser-token-cache
May 17, 2023
Merged

Persist token acquired through 'external-browser' auth type#110
nfx merged 1 commit intomainfrom
external-browser-token-cache

Conversation

@pietern
Copy link
Copy Markdown
Contributor

@pietern pietern commented May 15, 2023

Changes

This cache is local to the Python SDK and keyed off the workspace host, the OAuth client ID, and the list of scopes to authorize for. The cache path is ~/.config/databricks-sdk-py/oauth. Files saved to this directory are masked 0600.

It does not persist refreshes that happen during a session.

Tests

Reproduce by running ./examples/local_browser_oauth.py multiple times.

  • make test run locally
  • make fmt applied
  • relevant integration tests applied

This cache is local to the Python SDK and keyed off the workspace host,
the OAuth client ID, and the list of scopes to authorize for.

It does not persist refreshes that happen during a session.
@pietern pietern requested review from mgyucht and nfx May 15, 2023 14:58
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Patch coverage: 41.66% and project coverage change: +0.09 🎉

Comparison is base (5971ba4) 52.72% compared to head (f84cf2f) 52.81%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #110      +/-   ##
==========================================
+ Coverage   52.72%   52.81%   +0.09%     
==========================================
  Files          29       29              
  Lines       17067    17098      +31     
==========================================
+ Hits         8998     9031      +33     
+ Misses       8069     8067       -2     
Impacted Files Coverage Δ
databricks/sdk/core.py 65.14% <0.00%> (-0.52%) ⬇️
databricks/sdk/oauth.py 45.24% <55.55%> (+8.96%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.



class TokenCache():
BASE_PATH = "~/.config/databricks-sdk-py/oauth"
Copy link
Copy Markdown
Contributor

@nfx nfx May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it's better to use ~/.databricks/tokens

Copy link
Copy Markdown
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will make necessary renames later

@nfx nfx merged commit 1afdc73 into main May 17, 2023
@nfx nfx deleted the external-browser-token-cache branch May 17, 2023 09:33
nfx pushed a commit that referenced this pull request May 17, 2023
## Changes

This cache is local to the Python SDK and keyed off the workspace host,
the OAuth client ID, and the list of scopes to authorize for. The cache
path is `~/.config/databricks-sdk-py/oauth`. Files saved to this
directory are masked 0600.

It does not persist refreshes that happen during a session.

## Tests

Reproduce by running `./examples/local_browser_oauth.py` multiple times.

- [x] `make test` run locally
- [x] `make fmt` applied
- [x] relevant integration tests applied
@nfx nfx mentioned this pull request May 17, 2023
nfx added a commit that referenced this pull request May 17, 2023
# Version changelog

## 0.1.7

* Added an extensive set of examples ([#113](#113)).
* Fixed broken `dbutils.fs.mount` and `dbutils.fs.updateMount` ([#119](#119)).
* Ignore `.netrc` when sending unauthenticated requests for OAuth handshake ([#108](#108)).
* Make ApiClient more `pyodide` friendly ([#114](#114)).
* Persist token acquired through `external-browser` auth type ([#110](#110)).
* Prototype for notebook-native auth ([#115](#115)).
* Rename `RefreshableCredentials` to `SessionCredentials` ([#116](#116)).
* Use shell for opening `az` cli on Windows ([#117](#117)).
@nfx nfx mentioned this pull request May 17, 2023
nfx added a commit that referenced this pull request May 17, 2023
# Version changelog

## 0.1.7

* Added an extensive set of examples
([#113](#113)).
* Fixed broken `dbutils.fs.mount` and `dbutils.fs.updateMount`
([#119](#119)).
* Ignore `.netrc` when sending unauthenticated requests for OAuth
handshake
([#108](#108)).
* Make ApiClient more `pyodide` friendly
([#114](#114)).
* Persist token acquired through `external-browser` auth type
([#110](#110)).
* Prototype for notebook-native auth
([#115](#115)).
* Rename `RefreshableCredentials` to `SessionCredentials`
([#116](#116)).
* Use shell for opening `az` cli on Windows
([#117](#117)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants