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

Spring Boot对接Google Vertex AI认证失败问题求助

排查Vertex AI 'UNAUTHENTICATED' 异常步骤
  • 验证服务账号Vertex AI权限
    确认服务账号已绑定Vertex AI User(roles/aiplatform.user)或更高权限(如Vertex AI Admin),且权限是直接绑定到账号而非通过组继承——能访问Cloud Storage不代表拥有Vertex AI的操作权限。

  • 检查Credentials加载逻辑
    确保代码中明确加载了目标服务账号密钥,而非默认凭据:

    GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream("/path/to/your-service-account-key.json"));
    

    同时检查环境变量GOOGLE_APPLICATION_CREDENTIALS是否指向正确的密钥文件,避免配置冲突覆盖凭据。

  • 确认Vertex AI客户端配置
    初始化VertexAI客户端时必须指定模型部署的正确区域,区域不匹配会触发认证异常:

    VertexAI vertexAI = new VertexAI("your-project-id", "us-central1", credentials);
    

    验证生成式模型Bean是否关联了这个已授权的VertexAI实例。

  • 复查API启用状态
    确认项目中Vertex AI API(aiplatform.googleapis.com)已启用,仅开启Cloud Storage API不足以访问Vertex AI。部分API启用需要几分钟生效,若刚开通可稍等再测试。

  • 用CLI测试凭据有效性
    用gcloud命令直接验证服务账号的Vertex AI访问权限,排除代码问题:

    gcloud auth activate-service-account --key-file=/path/to/your-service-account-key.json
    gcloud ai models list --project=your-project-id --region=us-central1
    

    若命令失败,说明是凭据或权限问题;若成功,则聚焦代码中的配置疏漏。

  • 排查网络与代理限制
    若应用部署在私有环境或使用代理,确保允许访问aiplatform.googleapis.com的443端口,避免网络拦截导致认证请求失败。

内容的提问来源于stack exchange,提问作者Arnold Robert Turdean

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 16:25:04