Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24-Jan-2017 protocol change? Hangups [master] fails to run: hangups.exceptions.NetworkError: Request return unexpected status: 401: Unauthorized #298

Closed
pleasantone opened this issue Jan 24, 2017 · 10 comments

Comments

@pleasantone
Copy link

Username/password combination is correct and on authorized hosts (fails differently for security alert). OAuth negotiation was successful. Python 3.4

Hangups had been working on this machine previously (2 months ago), with this account, but this is, in fact, a new clone, so I don't know what rev master was at when last tested.

I suspect it's because of the API/Protocol change.

Traceback (most recent call last):
  File "/home/pst/hangups/.env/bin/hangups", line 9, in <module>
    load_entry_point('hangups==0.4.1', 'console_scripts', 'hangups')()
  File "/home/pst/hangups/hangups/ui/__main__.py", line 1010, in main
    }, col_scheme, palette_colors, datetimefmt, notifier
  File "/home/pst/hangups/hangups/ui/__main__.py", line 108, in __init__
    loop.run_until_complete(self._client.connect())
  File "/usr/lib/python3.4/asyncio/base_events.py", line 276, in run_until_complete
    return future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/home/pst/hangups/hangups/client.py", line 122, in connect
    yield from self._listen_future
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/home/pst/hangups/hangups/channel.py", line 203, in listen
    yield from self._fetch_channel_sid()
  File "/home/pst/hangups/hangups/channel.py", line 273, in _fetch_channel_sid
    res = yield from self.send_maps([])
  File "/home/pst/hangups/hangups/channel.py", line 248, in send_maps
    params=params, data=data_dict,
  File "/home/pst/hangups/hangups/http_utils.py", line 58, in fetch
    .format(res.status, res.reason)
hangups.exceptions.NetworkError: Request return unexpected status: 401: Unauthorized
Exception ignored in: <bound method TCPConnector.__del__ of <aiohttp.connector.TCPConnector object at 0x7f651be21ef0>>
Traceback (most recent call last):
  File "/home/pst/hangups/.env/lib/python3.4/site-packages/aiohttp/connector.py", line 159, in __del__
  File "/home/pst/hangups/.env/lib/python3.4/site-packages/aiohttp/connector.py", line 159, in <listcomp>
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 474, in __repr__
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 31, in _test_selector_event
AttributeError: 'NoneType' object has no attribute 'get_key'
@pleasantone
Copy link
Author

So it's choking in send_maps([]), ver = 8. Just for giggles, bumped ver to 9, failed.
Need to MITM a legit hangups connection and see what happens, but I don't have a good MITM jig for hangups. I assume you do, @tdryer? What are you using, charlesproxy or ?

@tdryer
Copy link
Owner

tdryer commented Jan 25, 2017

I usually use Chrome DevTools against the Hangouts web app.

hangups is still working for me, but Google if changed something it might not apply to all account simultaneously.

@pleasantone
Copy link
Author

Yeah, it looks like some servers/zones. Same test account, two machines, same env, west coast works, Miami fails.

@pleasantone
Copy link
Author

pleasantone commented Feb 14, 2017

Weirdest thing, seeing it at home now on the west coast. Logged into the same account from the same IP address using chrome and google.com/hangouts and everything is fine.

2017-02-14 14:09:04,598 - hangups.auth - INFO - Authenticating with refresh token
2017-02-14 14:09:04,598 - hangups.auth - INFO - Loading refresh_token from '/home/[redacted]/.cache/hangups/refresh_token.txt'
2017-02-14 14:09:04,601 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): accounts.google.com
2017-02-14 14:09:05,257 - requests.packages.urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "POST /o/oauth2/token HTTP/1.1" 200 None
2017-02-14 14:09:05,258 - hangups.auth - INFO - Authentication successful
2017-02-14 14:09:05,431 - requests.packages.urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "GET /accounts/OAuthLogin?source=hangups&issueuberauth=1 HTTP/1.1" 200 269
2017-02-14 14:09:05,624 - requests.packages.urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "GET /MergeSession?service=mail&continue=http://www.google.com&uberauth=[redacted]%0A HTTP/1.1" 302 316
2017-02-14 14:09:05,810 - requests.packages.urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "GET /CheckCookie?chtml=LoginDoneHtml&service=mail&continue=https%3A%2F%2Fwww.google.com&gidl=EgIIAA HTTP/1.1" 302 204
2017-02-14 14:09:05,813 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): www.google.com
2017-02-14 14:09:06,480 - requests.packages.urllib3.connectionpool - DEBUG - https://www.google.com:443 "GET / HTTP/1.1" 200 None
2017-02-14 14:09:06,489 - hangups.channel - INFO - Requesting new gsessionid and SID...
2017-02-14 14:09:06,490 - hangups.http_utils - DEBUG - Sending request post https://0.client-channel.google.com/client-channel/channel/bind:
{'ofs': 0, 'count': 0}
2017-02-14 14:09:07,142 - hangups.http_utils - DEBUG - Received response 401 Unauthorized:
b'<HTML>\n<HEAD>\n<TITLE>Unauthorized</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Unauthorized</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n'
2017-02-14 14:09:07,142 - hangups.http_utils - INFO - Request returned unexpected status: 401 Unauthorized

When I look at potentially relevant posts, I'm seeing that we're still running version 8...

Hmm, I wish there was a better way to get this data to you, would you prefer screenshots?

Request URL:https://hangouts.google.com/_/data?ds.extension=119186601&_reqid=51218&rt=j
Cookies: [redacted]
Form Data: f.req:[[[119186601,null,null,null,0]]]

request for photos:

Request URL:https://clients6.google.com/rpc?key=[redacted]&alt=json
{jsonrpc: "2.0", apiVersion: "v2", method: "plusi.ozinternal.readfeatureditems",…}
apiVersion:"v2"
id:"GetFeaturedPhotos-1"
jsonrpc:"2.0"
method:"plusi.ozinternal.readfeatureditems"
params:{itemMask: {metadata: {ownerRef: {}}, itemType: {photo: {image: {}}}, photosProductUrls: {}},…}
actorMask:{}
itemMask:{metadata: {ownerRef: {}}, itemType: {photo: {image: {}}}, photosProductUrls: {}}
itemsPerPage:30
sortOrder:{sortCriteria: 1}
Request URL:https://hangouts.google.com/webchat/_/datads.extension=51436515&_reqid=51219&rt=j
f.req:[[[51436515,null,null,null,0]]]
Request URL:https://clients6.google.com/rpc/plusi?key=[redacted]&alt=json
{method: "plusi.ozinternal.loadblockedpeople", id: "getBlockedUsers", apiVersion: "v2", jsonrpc: "2.0",…}
apiVersion:"v2"
id:"getBlockedUsers"
jsonrpc:"2.0"
method:"plusi.ozinternal.loadblockedpeople"
params:{includeChatBlocked: true, includeProfileInfo: "MEMBER_ID_ONLY"}
includeChatBlocked:true
includeProfileInfo:"MEMBER_ID_ONLY"
Request URL:https://hangouts.google.com/webchat/_/data?ds.extension=51436515&_reqid=51219&rt=j
f.req:[[[51436515,null,null,null,0]]]

VERSION 8!!! So version is the same...

Request URL:https://2.client-channel.google.com/client-channel/channel/bind?ctype=hangouts&prop=StartPage&appver=chat_frontend_20170208.12_p0&gsessionid=I_mHRZRGkeZ9e5vnYyn0J_asTEvtHmmf&VER=8&RID=rpc&SID=E7A1258F89C0C3D0&CI=0&AID=17&TYPE=xmlhttp&zx=hykl8p62qpsl&t=1
Request Method:GET
Status Code:200 
ctype:hangouts
prop:StartPage
appver:chat_frontend_20170208.12_p0
gsessionid:I_mHRZRGkeZ9e5vnYyn0J_asTEvtHmmf
VER:8
RID:rpc
SID:E7A1258F89C0C3D0
CI:0
AID:17
TYPE:xmlhttp
zx:hykl8p62qpsl
t:1

@Gauravtolani
Copy link

I faced the same issue.(I installed hangups using python3.4.2 first)
what worked for me:
unistall the project(or take backup and unistall if you have made some changes in the original repo)
unistall the 'hangups' file from 'usr/local/bin' directory(in case of linux). find your installation directory in case you are using some other OS.
reinstall everything using python3.5 instead and run it.

@anpetrov
Copy link

does not work for me. Same signature. python3.4.2, hangups 0.4.2 and .. uh, west cost as well

@snodo
Copy link

snodo commented Apr 13, 2017

I am trying to setup hangups - just started, so it never worked before.
Login seems to be fine: An iOS device was added to my account.

But now i ran into the exact same python traceback and have similar logfile entries as pleasantone pasted on 24. Jan and 14. Feb.
(Not West Coast but Germany.)

@SohumB
Copy link

SohumB commented Jun 1, 2017

Yeah, I can report this error as well on python3.4.2 and hangups 0.4.2 on the west coast. And yes, for some reason, using python 3.5 does indeed fix the issue.

@snodo
Copy link

snodo commented Jun 2, 2017

huh - indeed
I was using python3.4.2 aswell

with python3.5.2 it is working
Thank you!

@tdryer
Copy link
Owner

tdryer commented Jun 4, 2017

There was bug in aiohttp (aio-libs/aiohttp#1566) with Python 3.4.2 that can cause it to send a malformed cookie header. That would explain the "unauthorized" error.

I'll increase the minimum aiohttp version so the fix is included. Thanks to everyone for your reports!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants