oauth: add custom-app U2M OAuth with PKCE - #516
Draft
andy-xu-db wants to merge 1 commit into
Draft
Conversation
This was referenced Sep 8, 2026
Add the public-client authorization-code flow needed for custom Databricks OAuth apps. Use PKCE without a client secret and cache refresh tokens by workspace and client ID.
andy-xu-db
force-pushed
the
andy-xu_data/stack/oauth-pkce-module
branch
from
September 8, 2026 20:34
8ad18a8 to
196a2c6
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this does
Adds
src/ucode/oauth.py: the OAuth flow ucode needs to sign in through a custom Databricks OAuth app instead of the built-indatabricks-clione.Why: the built-in app's refresh token expires after 7 days. A custom app integration can go to 90, but no part of the Databricks CLI lets you select a client id.
authorization_code+ PKCE S256 (the only challenge method Databricks accepts) against/oidc/v1/{authorize,token}, or/oidc/accounts/<id>/v1/...for account-level apps.all-apis offline_access— the latter is what makes a refresh token come back.0600cache keyed by(host, client id).~/.databricks/token-cache.jsonrecords no client id, so a custom-app refresh token would be refreshed with the built-in client and rejected.Nothing calls it yet; #517 wires it in. Jira: AIGTWY-4550
Testing
uv run pytest2,290 passed (+41 vsorigin/main, same 21 pre-existing failures);ruff check,ruff format --check,ty check src/clean. Newtests/test_oauth.pycovers PKCE, both OIDC shapes, exchange, refresh, cache, expiry buffer, error hints.🥞 Stacked PR
This pull request and its description were written by Isaac.