googleapis / google-api-nodejs-client

Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
https://googleapis.dev/nodejs/googleapis/latest/
Apache License 2.0
11.36k stars 1.92k forks source link

Chat api : Error: Requested entity was not found when trying to list Spaces #1940

Closed jeromeSH26 closed 3 years ago

jeromeSH26 commented 4 years ago

Hi, I'm trying to list the spaces a user is member of. When querying, I got this error which I don't get the meaning. Using a service account that has the chat.bot scope available, and passing the user in the "subject" field when requesting the token. What is the issue then?

const auth = await getGoogleServiceAccountCredentials(
    credentials[0].scopes,
    credentials[0].credentials.client_email,
    credentials[0].credentials.private_key,
    useraccount,  <----user account I want the list of spaces
    credentials[0].credentials.private_key_id,
    undefined
);
const chat = google.chat({ version: "v1", auth });
const chatList = await chat.spaces.list();
console.log(chatList.data.spaces); 
adamsar commented 4 years ago

Same problem here for me:

Simple code to reproduce:

const keyFile = process.env["GOOGLE_CHAT_KEYFILE"]
const chatClient = google.chat({
        auth: new GoogleAuth({keyFile, scopes: ["https://www.googleapis.com/auth/chat.bot"]}),
        version: "v1"
    });
chatClient.spaces.list().then(response => console.log(response.data))

Key file obtained via instructions on https://developers.google.com/hangouts/chat/how-tos/service-accounts

Note that as per instructions I have not included any roles. this is on a fresh account with a single room in google chat.

adamsar commented 4 years ago

I'm beginning to think this is an issue with the rest API itself, as I can reproduce this outside the SDK by using the generated token. I've reported the issue the Chat API team.

fhinkel commented 3 years ago

Thanks for reporting the issue to the Chat API team. Looks like we can close this.