mautrix / googlechat

A Matrix-Google Chat puppeting bridge
https://matrix.to/#/#googlechat:maunium.net
GNU Affero General Public License v3.0
112 stars 30 forks source link

Receiving 401 Unauthorized Errors when Sending messages #91

Closed timaeos closed 1 year ago

timaeos commented 1 year ago

S/W Information mautrix / googlechat version: mautrix-googlechat 0.5.0 Client Versions : Nheko 0.11.3-d27e42d / FluffyChat 1.12.0 (Android) O/S: Fedora 38 KDE

What Happened:

Attempted to send a message from Matrix channel to a Google Chat. The Bridge bot persistently returned the message ⚠ Your message may not have been bridged: Request return unexpected status: 401: Unauthorized.

Messages from Google Chat -> Matrix still went through

Expected:

Should be able to bridge messages from Matrix -> Google Chat

Notes: Below are the logs for the error. I checked the areas of the code and it might be that Google changed that set_typing_state_request endpoint to require a different type of authorization. It also appears that the get_members_request endpoint is also returning an unauthorized error.

I attempted to reauthenticate by changing the cookie that I was using but after changing it twice and the bot responded that it successfully logged in, it still returned the authorization error.

To clarify, it was functioning earlier in the day with my original cookie and then later it ceased functioning, that's why I attempted to change the cookie.

I attempted turning off send receipt but that didn't appear to change the outcome as well.

Is it possible that Google already closed that new method of logging into the chat to send messages?

Jun 21 20:59:07 hermes mautrix-googlechat[1108657]: [2023-06-22 01:59:07,089] [ERROR@] Failed handling Matrix message 
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]: Traceback (most recent call last):
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:   File "/usr/lib/python3.11/site-packages/mautrix_googlechat/portal.py", line 899, in handle_matrix_message
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:     resp = await self._handle_matrix_text(sender, message, thread_id, local_id)
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:   File "/usr/lib/python3.11/site-packages/mautrix_googlechat/portal.py", line 1034, in _handle_matrix_text
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:     await sender.client.mark_typing(self.gcid, typing=False)
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:   File "/opt/mautrix-googlechat/maugclib/client.py", line 462, in mark_typing
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:     resp = await self.proto_set_typing_state(
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:   File "/opt/mautrix-googlechat/maugclib/client.py", line 751, in proto_set_typing_state
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:     await self._gc_request("set_typing_state", set_typing_state_request, response)
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:   File "/opt/mautrix-googlechat/maugclib/client.py", line 573, in _gc_request
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:     res = await self._base_request(
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:           ^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:   File "/opt/mautrix-googlechat/maugclib/client.py", line 639, in _base_request
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:     res = await self._session.fetch(
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:   File "/opt/mautrix-googlechat/maugclib/http_utils.py", line 164, in fetch
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]:     raise exceptions.NetworkError(
Jun 21 20:59:07 hermes mautrix-googlechat[1108657]: maugclib.exceptions.NetworkError: Request return unexpected status: 401: Unauthorized
[2023-06-22 02:15:34,259] [ERROR@mau.user] Failed to get own info
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]: Traceback (most recent call last):
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:   File "/usr/lib/python3.11/site-packages/mautrix_googlechat/user.py", line 528, in on_connect_later
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:     self_info = await self.get_self()
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:                 ^^^^^^^^^^^^^^^^^^^^^
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:   File "/usr/lib/python3.11/site-packages/mautrix_googlechat/user.py", line 454, in get_self
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:     resp = await self.client.proto_get_members(
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:   File "/opt/mautrix-googlechat/maugclib/client.py", line 668, in proto_get_members
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:     await self._gc_request("get_members", get_members_request, response)
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:   File "/opt/mautrix-googlechat/maugclib/client.py", line 573, in _gc_request
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:     res = await self._base_request(
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:           ^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:   File "/opt/mautrix-googlechat/maugclib/client.py", line 639, in _base_request
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:     res = await self._session.fetch(
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:   File "/opt/mautrix-googlechat/maugclib/http_utils.py", line 164, in fetch
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]:     raise exceptions.NetworkError(
Jun 21 21:15:34 hermes mautrix-googlechat[1115668]: maugclib.exceptions.NetworkError: Request return unexpected status: 401: Unauthorized
timaeos commented 1 year ago

Appears to have resolved itself? Closing this issue for now