You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

公司网络环境下Databricks-Connect无法连接的问题求助

解决Databricks Connect内网代理下的OIDC认证失败问题

问题核心

在内网环境使用Databricks Connect时,即便设置了HTTPS_PROXY环境变量(pip、Git等工具可正常使用),创建Spark会话仍因OIDC认证环节无法通过代理获取配置失败,报错显示访问OIDC的well-known端点时需认证。

解决方案

  • 同时配置大小写代理环境变量:部分工具对环境变量大小写敏感,建议同时设置:

    # Linux/macOS终端
    export http_proxy=http://proxy.company.com:port
    export https_proxy=http://proxy.company.com:port
    export HTTP_PROXY=http://proxy.company.com:port
    export HTTPS_PROXY=http://proxy.company.com:port
    
    # Windows命令行
    set http_proxy=http://proxy.company.com:port
    set https_proxy=http://proxy.company.com:port
    set HTTP_PROXY=http://proxy.company.com:port
    set HTTPS_PROXY=http://proxy.company.com:port
    

    也可直接在PyCharm的Run Configuration中添加这些环境变量。

  • 在databrickscfg中配置代理:打开.databrickscfg文件(Linux/macOS路径为~/.databrickscfg,Windows为%USERPROFILE%\.databrickscfg),在对应[myprofile]段添加代理配置:

    [myprofile]
    host = https://myworkspace
    cluster_id = mycluster
    http_proxy = http://proxy.company.com:port
    https_proxy = http://proxy.company.com:port
    
  • 验证代理通路:用curl测试代理能否正常访问OIDC端点,排查防火墙或代理权限问题:

    curl -x http://proxy.company.com:port https://myworkspace/oidc/.well-known/oauth-authorization-server
    

    返回JSON内容则代理通路正常;若仍提示认证失败,说明代理可能需要NTLM或其他身份验证。

  • 切换为PAT认证绕开OIDC流程:若OIDC代理问题无法解决,改用个人访问令牌(PAT)认证:

    1. 在Databricks工作区生成PAT(用户设置→访问令牌→生成新令牌)。
    2. 修改.databrickscfg对应profile:
      [myprofile]
      host = https://myworkspace
      cluster_id = mycluster
      token = <你的PAT令牌>
      auth_type = pat
      
    3. 重新运行代码,将直接使用PAT认证,无需走OIDC令牌获取流程。
  • 处理NTLM代理认证:若公司代理用NTLM认证,普通配置无效可尝试:

    • 在代理URL中包含凭证(注意安全风险):http://domain\\username:password@proxy.company.com:port
    • 使用proxychains-ng等工具封装代理请求(Linux/macOS)
    • 在Windows系统Internet选项中配置系统级代理并开启NTLM认证

内容的提问来源于stack exchange,提问作者arohland

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 05:38:14