I was using the post here: https://developers.google.com/chat/how-tos/service-accounts#creating_and_using_a_service_account to interact with Google Chat API. I've created the service account + enabled the API access as well as installing all the python dependencies/libraries.
However, I'm getting the following errors:
Traceback (most recent call last):
File "a.py", line 9, in <module>
body={'text': 'Test message'}).execute()
File "/usr/local/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/googleapiclient/http.py", line 937, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://chat.googleapis.com/v1/spaces/AAAAWtx0J9a/messages?alt=json returned "Invalid project number.". Details: "Invalid project number.">
Code:
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
scopes = 'https://www.googleapis.com/auth/chat.bot'
credentials = ServiceAccountCredentials.from_json_keyfile_name('gcapi-13221-bcbc7fe2b54b.json', scopes)
chat = build('chat', 'v1', http=credentials.authorize(Http()))
resp = chat.spaces().messages().create(
parent='spaces/AAAAWtx0J9a',
body={'text': 'Test message'}).execute()
print(resp)
Could anyone please shed some light on what I'm missing here?
Many thanks