I am trying to list the spaces of google chat by using this particular API
There are three ways to authenticate and call api
- Using API key
- Using OAuth
- Service account
With API Key and Service account I am getting error
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"
}
}
]
} }
On my third try I used the OAuth 2.0 Client IDs for the authentication , Like given below -
curl --location 'https://chat.googleapis.com/v1/spaces' \ --header 'Authorization: Bearer Access token of the user'
But this method is also giving me this error, even though i have enabled the chat app api from my Google Cloud console. -
{
"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"
}
]
}
]
}
}
What specific thing I am missing to make api call successfully?
I am expecting to utilize key give by the Service Accounts to access the particular chat and send message into the particular chat space.