【API测试工具错误报告】 错误码: 错误 401 - 无效令牌 错误: 详细信息:Request had invalid authentication cre...
🚨 错误信息
【API测试工具错误报告】
错误码: 错误 401 - 无效令牌
错误: 详细信息:Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
模型: gemini-2.5-pro
接口: https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent
令牌: AIzaSy...rsZ4
时间: 2025/10/2 19:00:04
🤖 AI解决方案
错误 401 - 无效令牌
Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.错误翻译:
请求具有无效的身份验证凭据。期望OAuth 2访问令牌、登录Cookie或其他有效的身份验证凭据。
原因分析
API密钥(令牌)无效或已过期,导致身份验证失败。
解决方案
* 前往 Google Cloud Console。
* 导航到 "API 和服务" > "凭据"。
* 创建一个新的 API 密钥,并替换掉旧的、无效的密钥。
"AIzaSy...rsZ4" 部分。