Fix cross-workspace auth for M2M app-to-app flow#183
Merged
calreynolds merged 1 commit intomainfrom Feb 25, 2026
Merged
Conversation
Two bugs prevented the M2M cross-workspace flow from working: 1. FMAPI (Claude API) was pointed at the target workspace instead of staying on the Builder App's workspace where the model serving endpoint lives. 2. get_workspace_client() always used env OAuth credentials (the Builder App's own SP), ignoring the explicit target workspace token set via set_databricks_auth(). Fix: - Add force_token flag to set_databricks_auth() that makes get_workspace_client() use the explicit token instead of env OAuth. Only set when cross-workspace params are provided — normal Builder App behavior is unchanged. - Split FMAPI and tools auth in the router: FMAPI always uses the Builder App's own workspace, tools use the target workspace. - Add fmapi_host/fmapi_token params to stream_agent_response to keep the two auth contexts separate. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Fixes two bugs that prevented the M2M cross-workspace flow from working:
get_workspace_client()ignored the target workspace token — always used the Builder App's own SP env credentials, even when explicit cross-workspace credentials were set viaset_databricks_auth()Adds a
force_tokenflag toset_databricks_auth()that makesget_workspace_client()use the explicit token instead of env OAuth. Only set when cross-workspace params are provided — normal Builder App behavior is unchanged.Splits FMAPI and tools auth: FMAPI always stays on the Builder App's workspace, tools target the caller-specified workspace.
Changes
databricks-tools-core/.../auth.pyforce_tokencontext var + kwarg onset_databricks_auth().get_workspace_client()checks it first.databricks-builder-app/.../routers/agent.pytarget_databricks_host/target_databricks_tokenon request model. Split FMAPI vs tools creds.databricks-builder-app/.../services/agent.pyfmapi_host/fmapi_token/is_cross_workspaceparams. FMAPI env usesfmapi_*, tools usedatabricks_*withforce_token.Test plan
e2-demo-field-eng)Made with Cursor