Skip to content

Google Chat Spaces Create #3507

@liamcharmer

Description

@liamcharmer

Hi i've been trying to create a google chat space automated via server. I am trying to use service account to do this request here;

However it comes back with the error;

"this method doesnt support service account authentication/ Authenticate with a user account."

I have followed this hyperlink to create the service account and it says it can take up to 24 hours for changes. May this just be the case?

https://developers.google.com/workspace/chat/authenticate-authorize-chat-app

const { GoogleAuth } = require('google-auth-library');
const key = require('./service-account-key.json');
const chat = require('@googleapis/chat');

exports.createChatSpace = async (req, res) => {
  try {
 
  const scopes = [
    'https://www.googleapis.com/auth/chat.spaces.create',
  ];

    // const scopes = ['https://www.googleapis.com/auth/chat.spaces'];

    const auth = new GoogleAuth({
      credentials: key,
      scopes: scopes
    });

    const authClient = await auth.getClient();

  const chatClient = await chat.chat({version: 'v1', auth: authClient});

const response= await chatClient.spaces.setup({
    requestBody: {
      space: {
        spaceType: 'SPACE',
        displayName: 'ASTEST',
      },
      memberships: [
      ]
    }
  });


    res.status(200).send(response.data);
  } catch (error) {
    console.error('Error creating chat space:', error);
    res.status(500).send(error.message);
  }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions