jaraco / googlevoice

Python Google Voice library based on pygooglevoice
MIT License
111 stars 32 forks source link

API has changed - leads to LoginError #8

Open MattLabs2004 opened 5 years ago

MattLabs2004 commented 5 years ago

Whenever I try to run this code I get this error I have tried searching for solutions but most are a few years old and didn't work. Any help would be appreciated

tazdevil1 commented 5 years ago

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
slow-quick commented 5 years ago

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'.

noor01 commented 5 years ago

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!

668168 commented 5 years ago

same issue,too

jaraco commented 5 years ago

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.

kolbashj commented 5 years ago

Also having the same problem...

dougollerenshaw commented 4 years ago

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?

jaraco commented 3 years ago

It does not work.

nijave commented 3 years ago

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

vpzomtrrfrt commented 2 years ago

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

vpzomtrrfrt commented 2 years ago

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):

xloem commented 1 year ago

It would make sense to stabilize the code in a way that requires the user to extract data from the browser for now.

nicholasf-at-schultztechnology commented 3 months ago

If you take the returned data and bring it into the browser you get this: image

And I guess that's already been established, but adding my 2 cents in.