英文:
Error: Google Chat app not found while listing members using Google REST API in TypeScript
问题
我正在尝试使用我的TypeScript后端从Google REST API列出Google Chat空间的成员。目前,我在实现此功能时遇到困难,以下是我的代码:
const { google } = require('googleapis');
async function authenticate() {
const auth = new google.auth.GoogleAuth({
keyFile: './pmtest-112533-5b83338226fd.json',
scopes: ['https://www.googleapis.com/auth/chat.spaces'],
});
return await auth.getClient();
}
async function getSpacesList() {
const client = await authenticate();
const chat = google.chat({ version: 'v1', auth: client });
return await chat.spaces.list();
}
getSpacesList()
.then(response => {
console.log('response:', response.data);
})
.catch(error => {
console.error('Error:', error);
});
并且我收到以下错误消息:
GaxiosError: 找不到Google Chat应用程序。要创建Chat应用程序,您必须打开Chat API并在Google Cloud控制台中配置该应用程序。
问题可能是什么?
英文:
I am trying to list members of a Google Chat space using the Google REST API from my TypeScript backend. Currently, I am facing difficulties in implementing this functionality, this is my code:
const { google } = require('googleapis');
async function authenticate() {
const auth = new google.auth.GoogleAuth({
keyFile: './pmtest-112533-5b83338226fd.json',
scopes: ['https://www.googleapis.com/auth/chat.spaces'],
});
return await auth.getClient();
}
async function getSpacesList() {
const client = await authenticate();
const chat = google.chat({ version: 'v1', auth: client });
return await chat.spaces.list();
}
getSpacesList()
.then(response => {
console.log('response:', response.data);
})
.catch(error => {
console.error('Error:', error);
});
and I have this error message:
GaxiosError: 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.
What could be the problem?
答案1
得分: 0
错误消息非常明确。在尝试访问他们的API之前,您需要启用Chat API并在Google Cloud控制台中配置应用程序。
要启用Chat API,您可以访问以下链接:
https://console.cloud.google.com/flows/enableapi?apiid=chat.googleapis.com
此外,您需要一个具有访问Google Chat权限的Google Workspace帐户。Google Chat API不适用于免费的Google帐户(Gmail)。
还请确保您的凭据正确,并与已启用Google Chat API的项目相关联。
英文:
The error message is very clear. You need to turn on the Chat API and configure the app in the Google Cloud console before trying to hit their API.
To enable the Chat API, you can visit the following link:
https://console.cloud.google.com/flows/enableapi?apiid=chat.googleapis.com
Additionally, you need a Google Workspace account with access to Google Chat. The Google Chat API will not work with a free Google account (Gmail).
Also, please ensure that your credentials are correct and associated with the project that has already enabled the Google Chat API.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论