tdryer / hangups

the first third-party instant messaging client for Google Hangouts
https://hangups.readthedocs.io/
MIT License
1.71k stars 190 forks source link

Add captcha support #446

Open xolox opened 5 years ago

xolox commented 5 years ago

Context: As explained in #445 I integrated hangups in my chat-archive program a few months ago. Back then (August 2018) hangups worked fine for me, but a few weeks ago the authentication started failing and try as I might I could not get it to work again :slightly_frowning_face:.

Disclaimer: Initially I had assumed I'd done something stupid when integrating hangups (even though it had worked before) but using python -m hangups.auth helped to confirm that my authentication problems had nothing to do with the integration between hangups and chat-archive.

Analysis:

Resolution:

[1] When I say "reasonable" I'm thinking about the potential audience of my chat-archive program, whom I'm not comfortable asking to open a pdb prompt or use the "Web Developer Tools" to extract a cookie from a browser session.

Expectation management:

I expect that hangups is used in a lot of different contexts (CLI, GUI, headless?) and I guess the webbrowser.open() call might be deemed inappropriate, however:

  1. The webbrowser.open() call is located inside CredentialsPrompt so that this behavior can easily be overridden by extending.

  2. The captcha image URL is logged so that the user can manually open it if the use of webbrowser.open() doesn't work.

  3. AFAICT when the captcha challenge is presented there was formerly (before this pull request) no way for hangups to ever finish successfully, so in that sense backwards compatibility shouldn't be a concern.

If there's problems with my current implementation that need to be resolved before this can be merged, feel free to let me know, because I'd love to see this get merged. While this new functionality is likely to be fragile, right now it's definitely an added value for me :slightly_smiling_face:.