API has changed - leads to LoginError
MattLabs2004 opened this issue · comments
I can't login since 2/14/2018:
C:\Users\johndoe\Anaconda3\python.exe
... xyz.py
Traceback (most recent call last):
File "C:\Users\johndoe\Anaconda3\lib\site-packages\googlevoice\voice.py", line 99, in login
assert self.special
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
....
voice.login()
File "C:\Users\johndoe\Anaconda3\lib\site-packages\googlevoice\voice.py", line 101, in login
raise util.LoginError
googlevoice.util.LoginError
Turned on debugger in PyCharm and the issue is in module voice.py, class Voice
def special(self):
"""
Returns special identifier for your session (if logged in)
"""
if getattr(self, '_special', None):
return self._special
pattern = re.compile(r"('_rnr_se':) '(.+)'")
resp = self.session.get(settings.INBOX).text
try:
sp = pattern.search(resp).group(2)
except AttributeError:
sp = None
self._special = sp
return sp
Strangely the resp does not contain the pattern, there's even no string '_rnr_se'.
I have been receiving the same issue since the beginning of this month as @tazdevil1 pointed out. Probably Google Voice has changed their AngularJS interface again, breaking the pygooglevoice scraper yet again (https://stackoverflow.com/questions/42097689/pygoogle-voice-not-logging-in).
I personally have no idea how to fix the scraper but am hoping that someone is able to make the quick fix!
same issue,too
The best course of action may be to focus on #7, although I'd happily accept a patch to retain the current behavior. Or it may be the case that the new HTML app is actually using the new API, in which case #7 is probably the shortest path to success. I won't have time to develop this myself, but I welcome contributions.
Also having the same problem...
I'm getting the same error trying to run on a raspberry pi:
Traceback (most recent call last):
File "/home/pi/miniconda3/envs/googlevoice/lib/python3.4/site-packages/googlevoice/voice.py", line 99, in login
assert self.special
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/miniconda3/envs/googlevoice/lib/python3.4/site-packages/googlevoice/voice.py", line 101, in login
raise util.LoginError
googlevoice.util.LoginError
Looks like the suggestion or work on #7 is stalled out.
Does anyone have ideas for a fix, or suggestions for other packages that allow GoogleVoice access with Python?
It does not work.
Looks like the current login page requires Javascript
The browser you’re using doesn’t support JavaScript, or has JavaScript turned off.
To keep your Google Account secure, try signing in on a browser that has JavaScript turned on. Learn more
Seems like the web client does
GET https://accounts.google.com/o/oauth2/iframerpc?action=listSessions&client_id=301778431048-buvei725iuqqkne1ao8it4lm0gmel7ce.apps.googleusercontent.com&origin=https://voice.google.com&scope=https://www.googleapis.com/auth/googlevoice https://www.googleapis.com/auth/notifications https://www.googleapis.com/auth/peopleapi.readwrite https://www.googleapis.com/auth/sipregistrar-3p&ss_domain=https://voice.google.com
which returns a list of sessions (which lines up with the account selector in the top right on the web gui). Then it does
GET https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token&login_hint=<ID FROM THE PREVIOUS COMMAND>&client_id=301778431048-buvei725iuqqkne1ao8it4lm0gmel7ce.apps.googleusercontent.com&origin=https://voice.google.com&scope=https://www.googleapis.com/auth/googlevoice https://www.googleapis.com/auth/notifications https://www.googleapis.com/auth/peopleapi.readwrite https://www.googleapis.com/auth/sipregistrar-3p&ss_domain=https://voice.google.com
which returns a bearer token.
After that, it's then making requests like
POST https://content.googleapis.com/voice/v1/voiceclient/<some operation>/get?alt=protojson
So I guess the first part is to "login" to a Google account which sets some cookies (maybe some other project has done that?). After that step, it looks like you just issue a bearer token and go with that
From further experimentation, it appears that the iframerpc calls require the header "X-Requested-With: XmlHttpRequest" and the cookies "SID", "__Secure_3PSID", and "LSID" in order to return a result
Incoming messages can be listed with https://content.googleapis.com/voice/v1/voiceclient/api2thread/list?alt=json
(the site uses "alt=protojson" but json is also available and seems nicer). I send a POST request with the body [2,20,15,null,null,[null,true,true]]
(dunno what it means but it works) and a Content-Type of "application/json+protobuf".
Messages can be sent with https://content.googleapis.com/voice/v1/voiceclient/api2thread/sendsms?alt=json
. The body for this is a 9-element array (at least in the one example I saw):
- 0-3 are all null
- 4 contains the message text
- 5 contains the Thread ID to send to
- 6 is an empty array
- 7 is null
- 8 is a one-element array. The element is a number which appears to be used as a nonce (if another request is sent with the same nonce, it is ignored)
It would make sense to stabilize the code in a way that requires the user to extract data from the browser for now.