Title: Default authentication chain doesn't work on Databricks Apps · Issue #651 · databricks/databricks-sql-python · GitHub
Open Graph Title: Default authentication chain doesn't work on Databricks Apps · Issue #651 · databricks/databricks-sql-python
X Title: Default authentication chain doesn't work on Databricks Apps · Issue #651 · databricks/databricks-sql-python
Description: I am developing a Streamlit app for deployment to Databricks Apps. I am having trouble getting the same authentication flow to work both locally as well as on Databricks Apps. Consider the following snippet: from databricks import sql wi...
Open Graph Description: I am developing a Streamlit app for deployment to Databricks Apps. I am having trouble getting the same authentication flow to work both locally as well as on Databricks Apps. Consider the followin...
X Description: I am developing a Streamlit app for deployment to Databricks Apps. I am having trouble getting the same authentication flow to work both locally as well as on Databricks Apps. Consider the followin...
Opengraph URL: https://github.com/databricks/databricks-sql-python/issues/651
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Default authentication chain doesn't work on Databricks Apps","articleBody":"I am developing a Streamlit app for deployment to Databricks Apps. I am having trouble getting the same authentication flow to work both locally as well as on Databricks Apps.\n\nConsider the following snippet:\n\n```python\nfrom databricks import sql\n\nwith sql.connect(\n server_hostname=host,\n http_path=http_path,\n catalog=catalog,\n) as connection:\n with connection.cursor() as cursor:\n cursor.execute(\"SELECT 1\")\n result = cursor.fetchall()\n```\n\nThis works fine locally.\n\nHowever, when I deploy this to Databricks Apps, it just hangs forever.\n\nI figured out that to get this snippet to work on Databricks Apps, it needs this tweak:\n\n```python\nfrom databricks.sdk.core import Config\n\nwith sql.connect(\n server_hostname=host,\n http_path=http_path,\n catalog=catalog,\n credentials_provider=lambda: Config().authenticate,\n) as connection:\n ...\n```\n\nThis works on Databricks Apps, but now when I try to run it locally I get a new error:\n\n```\nValueError: default auth: cannot configure default credentials, please check \nhttps://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication\nto configure credentials for your preferred authentication method.\n```\n\nOK great. I have one thing that works locally but not on Databricks Apps, and another that works the other way around.\n\nUsing [the tip shared here][1], I combined these into a hybrid approach that seems to work both locally and on Databricks Apps:\n\n```python\nfrom databricks.sdk.core import Config, databricks_cli\n\ndef universal_databricks_credentials_provider():\n try:\n return databricks_cli(Config(host=host))\n except:\n return Config().authenticate\n\nwith sql.connect(\n server_hostname=host,\n http_path=http_path,\n catalog=catalog,\n credentials_provider=universal_databricks_credentials_provider,\n) as connection:\n ...\n```\n\nBut this is all very awkward and unpleasant.\n\nI think the default authentication chain that this library uses should work on Databricks Apps so that I don't have to specify `credentials_provider`.\n\n[1]: https://github.com/databricks/databricks-sql-python/issues/148#issuecomment-2271561365","author":{"url":"https://github.com/nchammas","@type":"Person","name":"nchammas"},"datePublished":"2025-07-23T20:13:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/651/databricks-sql-python/issues/651"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:80bcdd84-2559-621d-c41d-193122fcddbf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6F6:3BB2E8:15F9CDA:1EB9BBC:6970D364 |
| html-safe-nonce | 4d3a3515ea59c1d34e056e50a4ab99fa7718923edf7645f7c29c160ebddb3d87 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkY2OjNCQjJFODoxNUY5Q0RBOjFFQjlCQkM6Njk3MEQzNjQiLCJ2aXNpdG9yX2lkIjoiMjk2NjU5MTk5ODI1MzkxMjkzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1cd7ab9dab81582648d428e2d2eaaeb9496faf38994ff729b76af29068f745f8 |
| hovercard-subject-tag | issue:3257580978 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/databricks/databricks-sql-python/651/issue_layout |
| twitter:image | https://avatars.githubusercontent.com/u/4998052?s=400&v=4 |
| twitter:card | summary |
| og:image | https://avatars.githubusercontent.com/u/4998052?s=400&v=4 |
| og:image:alt | I am developing a Streamlit app for deployment to Databricks Apps. I am having trouble getting the same authentication flow to work both locally as well as on Databricks Apps. Consider the followin... |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nchammas |
| hostname | github.com |
| expected-hostname | github.com |
| None | 034aaee9edccd455c18591b13122193c6e12dc773e8a203be73abe934f3e3a72 |
| turbo-cache-control | no-preview |
| go-import | github.com/databricks/databricks-sql-python git https://github.com/databricks/databricks-sql-python.git |
| octolytics-dimension-user_id | 4998052 |
| octolytics-dimension-user_login | databricks |
| octolytics-dimension-repository_id | 493695132 |
| octolytics-dimension-repository_nwo | databricks/databricks-sql-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 493695132 |
| octolytics-dimension-repository_network_root_nwo | databricks/databricks-sql-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 52d1d534d0b88c64972e852deb460d09b433b8b2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width