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

执行gcloud认证命令遇Error 400: invalid_scope问题求助

解决gcloud auth application-default login时的invalid_scope错误

问题详情

执行命令:

!gcloud auth application-default login --client-id-file client_secret.json --scopes='https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning'

触发如下错误:

Some requested scopes were invalid. {invalid=[https://www.googleapis.com/auth/generative-language.tuning', 'https://www.googleapis.com/auth/cloud-platform]} Learn more about this error
If you are a developer of agribot, see error details.
Error 400: invalid_scope

已尝试在云端配置敏感权限范围,但问题仍未解决。

解决方案

  • 修正命令的单引号格式:从错误信息能看到,请求的scope被错误带上了单引号(一个末尾多了',一个开头多了'),这是单引号包裹scope值时的解析异常导致的。调整命令,去掉scope值两端的单引号,或者改用双引号包裹:

    !gcloud auth application-default login --client-id-file client_secret.json --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning
    

    或者:

    !gcloud auth application-default login --client-id-file client_secret.json --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning"
    
  • 确认scope的有效性与配置:

    • 检查https://www.googleapis.com/auth/generative-language.tuning是否适用于你的项目:该scope属于Gemini API的调优权限,需确保项目已启用Gemini API。
    • 确认OAuth同意屏幕已添加该scope:即使是敏感scope,也要在GCP控制台的OAuth同意屏幕中添加并完成发布流程(测试版或正式版)。
  • 验证client_secret.json文件:确保该文件是从GCP控制台正确下载的OAuth 2.0客户端ID文件,文件内的client_id、client_secret等信息无误,且客户端类型(如桌面应用)支持使用指定的scope。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 10:01:08