The Hangouts Chat REST API provides a way for bots to establish context for their operation. You can use the API to perform the following operations:
- List the spaces that the bot has been added to
- List the members that belong to a space
- Create, delete, and modify messages
To use this API, you must create a service account and use the service account to invoke the API. The service account must be authenticated before you can do this, because there is no interactive auth flow for service accounts.
For details, see the reference documentation or go directly to the documentation for specific methods:
- spaces.get Returns a space.
spaces.list Lists spaces the bot belongs to.
spaces.members.get Returns a member.
spaces.members.list Lists humans (not bots) that belong to the space.
spaces.messages.create Creates a message.
- spaces.messages.delete Deletes a message.
- spaces.messages.get Returns a message.
- spaces.messages.update Updates a message.
Authorizing the service account
Before making any calls to the API, your code needs to authenticate using OAuth 2.0, with credentials for the service account associated with your bot. The authorization call will resemble this one from the async HTTP bot sample:
scopes = ['https://www.googleapis.com/auth/chat.bot'] credentials = ServiceAccountCredentials.from_json_keyfile_name( 'service-acct.json', scopes) http_auth = credentials.authorize(Http())
Do not try and authorize using end-user credentials.
Locating the discovery document
The discovery document for this API is located at the following URL: