pettazz / pygooglevoice

Fixed version of pygooglevoice cloned from googlecode project that hasn't been updated since 2009.
BSD 3-Clause "New" or "Revised" License
181 stars 118 forks source link

Did google change the way logging in works? #24

Open jwerardi opened 8 years ago

jwerardi commented 8 years ago

My scripts worked fine on Friday. I ran them again today, and I'm facing an error when the API is trying to login.

googlevoice\voice.py", line 95, in login raise LoginError googlevoice.util.LoginError

alexcushing commented 8 years ago

wow Im having the exact same issue! help!

woodyl commented 8 years ago

Worked for me yesterday, failing today. If anybody figures out what changed, please post here!

tom-slick commented 8 years ago

They added a new input type on the login form "gxf"

you can try editing voice.py

        # holy hackjob
        galx = re.search(r"type=\"hidden\"\s+name=\"GALX\"\s+value=\"(.+)\"", content).group(1)
        gxf = re.search(r"type=\"hidden\"\s+name=\"gxf\"\s+value=\"(.+)\"", content).group(1)
        result = self.__do_page('login', {'Email': email, 'Passwd': passwd, 'GALX': galx, 'gxf':gxf})
ErinMorelli commented 8 years ago

It's more than just the new input type, it looks like they've changed the login POST URL as well. I have committed working changed to my fork of this repo and I've submitted it as a pull request (#25)

tom-slick commented 8 years ago

With the version I'm using I only needed to add the gxf bit

jwerardi commented 8 years ago

Thank you so much @ErinMorelli ! Your fixes worked perfectly :)

How did you figure this out, if you don't mind me asking? I was suspicious that it was the post parameters being changed, but I'm still fairly new to all of this and I didn't know how to diagnose the problem.

woodyl commented 8 years ago

Like tom-slick, I was able to fix my (heavily hacked) version by just adding the 'gxf" field to the existing code.

chris001 commented 8 years ago

@woodyl What else have you modified besides the 'gxf' field? Could you share your heavily hacked version? Because the "master" version here is failing to login.

woodyl commented 8 years ago

This is probably the relevant section:

        content = self.__do_page('login').read()
        # holy hackjob
        galx = re.search(b'type="hidden"\s*name="GALX"\s*value="([^"]+)"', content).group(1)
        gxf = re.search(b'type=\"hidden\"\s*name=\"gxf\"\s*value=\"([^"]+)"', content).group(1)
        # galx = re.search(b'name="GALX"\s*type="hidden"\n\s*value="([^"]+)"', content).group(1)
        # self.__do_page('login', {'Email': email, 'Passwd': passwd, 'GALX': galx})
        self.__do_page('login', {'Email': email, 'Passwd': passwd, 'GALX': galx, 'gxf': gxf})

I have borrowed snippets of code from various versions of pygooglevoice to keep my installation running and I didn't document where the code came from or what changes I made over time. The result is that the version I'm running is mostly the same as the pettazz version, but diverges sometimes. Let me know if this snippet gets yours running again. Also, note that this snippet was adapted for Python3 and might not be backward compatible with Python2.

chris001 commented 8 years ago

Thanks for that tip! @woodyl :beers: FYI for anyone else with this issue. The master code from the pettazz repo is working. The problem is gvoice security. You must do the "gvoice reset procedure", which allows the gvoice app to login from the new "Device," when you're running this code on a device which is different device from your usual pc/device. GVoice reset procedure: https://accounts.google.com/DisplayUnlockCaptcha

    Allow access to your Google account
    As a security precaution, Google may require you to complete this additional step when signing into a new device or application.

    To allow access, click the Continue button below.
nalipaz commented 7 years ago

I am unable to get the login to work using the suggested procedure by @chris001, and I also tested a few other possible solutions found here. Nothing seems to authenticate me, but maybe I differ from some of you in that this is the first time I have set this up. I am using 2-factor authentication. I do initially get my sms to verify the code. I am however never prompted to input it when the voice.login() method runs. I attempt to input it manually in the ~/.gvoice file which does get me further only to receive:

$ python2 examples/phones.py
DEBUG:PyGoogleVoice:e.com/ServiceLogin?service=grandcentral&passive=1209600&continue=https://www.google.com/voice&followup=https://www.google.com/voice&ltmpl=open? - {'User-Agent': 'PyGoogleVoice/0.5'}
DEBUG:PyGoogleVoice:e.com/signin/challenge/sl/password?service=grandcentral&continue=https://www.google.com/voice&followup=https://www.google.com/voice&ltmpl=open?Passwd=[censored]&gxf=AFoagUVc900kmoK4BIol84l-J990ANsHmw%3A1479973777423&GALX=MVDLdmI1Dac&Email=[censored] - {'User-Agent': 'PyGoogleVoice/0.5'}
Traceback (most recent call last):
  File "examples/phones.py", line 4, in <module>
    voice.login()
  File "/usr/local/lib/python2.7/dist-packages/googlevoice/voice.py", line 96, in login
    raise LoginError
googlevoice.util.LoginError

note I have censored some sensitive data in the debug output above

nalipaz commented 7 years ago

I spent my evening trying to sort this out. However, I made very little progress. I did attempt using lynx to do all browser authentication from the server I am running pygooglevoice on. That seemed like it would work, but ultimately it seemed like the same issue. I generated an app password at the recommendation of google which stops the sms code messages (2-factor verification), but still does not make any of this work.

chris001 commented 7 years ago

@nalipaz I'm not running 2 factor auth here, so it's possibly a bug. When you temporarily disable 2 factor auth does it work.

nalipaz commented 7 years ago

Okay, yes disabling two-factor authentication causes everything to work. So I guess I will have to jump on the band-wagon with the report of two-factor authentication not working.

extrem0 commented 7 years ago

Did anyone noticed it stop worked recently? I'm afraid it's related to the recent changes Google did with Google voice layout. For those who aren't affected, avoid logging in you gvoice account, otherwise you'll lose the ability to use this script. Legacy's Google voice page is now Google.com/voice/b/0. I tried changing it in settings.py but it didn't fix. There is something else needed.

nalipaz commented 7 years ago

@extrem0 I haven't yet noticed it stopped working but looking at the new UI (just saw it a moment after reading your post) I bet this is broken. From what I gathered looking at the code it is loading up the pages and parsing through, so id's, form names, and classes likely changed.

nalipaz commented 7 years ago

I can confirm my script for toggling a phone's enabled state no longer works.

jaronphillips commented 5 years ago

Looks like this might not be working again. it was working fine this morning, i have not changed code and i am getting this again. googlevoice.util.LoginError