Skip to content

Send a Google Chat message in Python without Workspace account #118

@richlegrand

Description

@richlegrand

I'm trying to send a Google Chat message from Python in much the same way you can send a Gmail message:

https://developers.google.com/gmail/api/quickstart/python

I see documentation on how to create a Chat Bot (https://developers.google.com/chat/how-tos/bots-develop), but these typically require that you create your own https server that google can access.

I've tried using the scope 'https://www.googleapis.com/auth/chat', and it successfully goes through the authorization flow, and in particular the 'chat' scope claims to grant permissions to send messages, etc:

(see https://vizycam.com/wp-content/uploads/2022/01/Image-634-1.jpg)

I can build a request using build() and the granted credentials:

from googleapiclient.discovery import build
...
service = build('chat', 'v1', credentials=gcloud.creds())
and I can see that it has methods dms(), rooms(), spaces(), etc. that I could use to create a message, but I'm unable to get any requests to work.

Is it possible to send a chat message from a user account programmatically, in much the same way the Gmail example above does?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions