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

API has changed - leads to LoginError #8

Open
MattLabs2004 opened this issue Jan 21, 2019 · 13 comments
Open

API has changed - leads to LoginError #8

MattLabs2004 opened this issue Jan 21, 2019 · 13 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@MattLabs2004
Copy link

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
Copy link

tazdevil1 commented Feb 16, 2019

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
Copy link

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
Copy link

noor01 commented Feb 19, 2019

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
Copy link

668168 commented Feb 20, 2019

same issue,too

@jaraco jaraco added bug Something isn't working help wanted Extra attention is needed labels Feb 20, 2019
@jaraco jaraco changed the title Trouble logging in API has changed - leads to LoginError Feb 20, 2019
@jaraco
Copy link
Owner

jaraco commented Feb 20, 2019

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
Copy link

Also having the same problem...

@dougollerenshaw
Copy link

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 added a commit that referenced this issue May 2, 2020
Co-authored-by: Jason R. Coombs <[email protected]>
@jaraco
Copy link
Owner

jaraco commented Dec 23, 2020

It does not work.

@nijave
Copy link

nijave commented May 14, 2021

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
Copy link

vpzomtrrfrt commented Oct 10, 2021

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
Copy link

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)

@xloem
Copy link

xloem commented Nov 8, 2022

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
Copy link

nicholasf-at-schultztechnology commented Jun 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests