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?