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

Google Chat API认证及调用失败问题排查求助

调用Google Chat API列出聊天空间的认证配置问题

我尝试调用Google Chat API列出聊天空间,已知有三种API认证调用方式:1. 使用API key;2. 使用OAuth;3. 使用服务账号。但使用API key和OAuth 2.0 Client IDs认证时均报错,服务账号调用也失败。具体错误信息如下:

API key调用报错

调用命令:
curl --location 'https://chat.googleapis.com/v1/spaces?key=xxxx-xxxx-xxxx-xxxx'

错误返回:

{     "error": {         
"code": 401,         
"message": "API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal. See https://cloud.google.com/docs/authentication",         
"status": "UNAUTHENTICATED",         
"details": [            
 {                 
"@type": "type.googleapis.com/google.rpc.ErrorInfo",                 
"reason": "CREDENTIALS_MISSING",                
 "domain": "googleapis.com",                
 "metadata": {                    
 "service": "chat.googleapis.com",                     
"method": "google.chat.v1.ChatService.ListSpaces"
                 }            
 }        
 ]     
} }

OAuth 2.0调用报错

调用命令:
curl --location 'https://chat.googleapis.com/v1/spaces' \ --header 'Authorization: Bearer Access token of the user'

错误返回:

{
    "error": {
        "code": 404,
        "message": "Google Chat app not found. To create a Chat app, you must turn on the Chat API and configure the app in the Google Cloud console.",
        "status": "NOT_FOUND",
        "details": [
            {
                "@type": "type.googleapis.com/google.rpc.Help",
                "links": [
                    {
                        "description": "To turn on the Google Chat API, go to the Google Chat API page in the Google Cloud console and click Enable.",
                        "url": "https://console.cloud.google.com/marketplace/product/google/chat.googleapis.com"
                    }
                ]
            },
            {
                "@type": "type.googleapis.com/google.rpc.Help",
                "links": [
                    {
                        "description": "To configure your Chat app, go to the Google Chat API Configuration tab in the Google Cloud console.",
                        "url": "https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat"
                    }
                ]
            },
            {
                "@type": "type.googleapis.com/google.rpc.Help",
                "links": [
                    {
                        "description": "To learn about creating Google Chat apps, visit the documentation.",
                        "url": "https://developers.google.com/chat"
                    }
                ]
            }
        ]
    }
}

我已在Google Cloud控制台启用Chat API,但仍出现上述错误。请问我缺少哪些具体配置才能成功调用API?我最终期望使用服务账号密钥访问指定聊天空间并发送消息。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 01:17:48