Brad Spencer
Brad Spencer

Reputation: 1

Getting an empty object when calling chat.spaces.list with service account authentication

I've set up a service account that works great with Admin SDK, but now I am trying to query a list of chat spaces and just getting an empty object back. I also set up the SA with domain-wide delegation and set my scope as https://www.googleapis.com/auth/chat.bot. This is all within a Google Workspace for Education domain in which I'm a super admin.

My code:

  const auth = await google.auth.getClient({
    keyFile: '/path/to/keyfile.json',
    scopes: [
      'https://www.googleapis.com/auth/chat.bot',
    ],
  })
  const chat = google.chat({ version: 'v1', auth })
  const res = await chat.spaces.list()

Do I need to specify a user I want to impersonate? I know the SA auth is limited for chat, but I was hoping it would do what I needed.

I also tried using a filter:

  const res = await chat.spaces.list({
    filter: 'spaceType = "SPACE"',
  })

and with a subject:

  const auth = await google.auth.getClient({
    keyFile: '/path/to/keyfile.json',
    scopes: [
      'https://www.googleapis.com/auth/chat.bot',
    ],
    subject: '[email protected]',
  })

both return a 200 OK, but empty data object.

Upvotes: 0

Views: 17

Answers (0)

Related Questions