Repository: tdryer/hangups

Issue #350: Support for Google provided email accounts (i.e. myusername@myuniversity.edu)
Created: 2017-07-24T18:51:31Z
I'm attempting to login with my Google-provided account. The domain-name part of the address is not gmail.com but rather my organization's domain name. Is there support for this and I'm just missing something?

Duplicate issue #438: Can't login with client or API
Created: 2018-11-11T17:13:01Z
I have a clean hangups installation from pip, version 0.4.6.  I am unable to log into my account from a Google account that has 2-factor authentication, using either the native password OR an app-password.
When using the client, I get the error:
Login failed (Authorization code cookie not found)

This is even when specifying the token-path to a blank file (or without that).  The log file contains:
2018-11-11 10:09:04,759 - hangups.auth - INFO - Authenticating with refresh token
2018-11-11 10:09:04,759 - hangups.auth - INFO - Loading refresh_token from 'token.txt'
2018-11-11 10:09:04,761 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): accounts.google.com:443
2018-11-11 10:09:04,951 - urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "POST /o/oauth2/token HTTP/1.1" 400 None
2018-11-11 10:09:04,951 - hangups.auth - INFO - Failed to authenticate using refresh token: Token request failed: 400 Client Error: Bad Request for url: https://accounts.google.com/o/oauth2/token
2018-11-11 10:09:04,952 - hangups.auth - INFO - Authenticating with credentials
2018-11-11 10:09:04,995 - urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "GET /o/oauth2/programmatic_auth?client_id=##########.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthLogin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email HTTP/1.1" 302 0
2018-11-11 10:09:05,076 - urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "GET /ServiceLogin?passive=1209600&continue=https://accounts.google.com/o/oauth2/programmatic_auth?client_id%##########.apps.googleusercontent.com%26scope%3Dhttps://www.google.com/accounts/OAuthLogin%2Bhttps://www.googleapis.com/auth/userinfo.email%26from_login%3D1%26as%##########&followup=https://accounts.google.com/o/oauth2/programmatic_auth?client_id%##########.apps.googleusercontent.com%26scope%3Dhttps://www.google.com/accounts/OAuthLogin%2Bhttps://www.googleapis.com/auth/userinfo.email%26from_login%3D1%26as%##########&ltmpl=embedded&oauth=1&sarp=1&scc=1 HTTP/1.1" 200 None
2018-11-11 10:09:09,987 - hangups.auth - INFO - Submitting form on page 'https://accounts.google.com/ServiceLogin'
2018-11-11 10:09:09,987 - hangups.auth - INFO - Page contains forms: ['gaia_loginform']
2018-11-11 10:09:09,987 - hangups.auth - INFO - Page contains inputs: [None, None, None, None, None, None, None, None, None, 'profile-information', 'session-state', None, '_utf8', 'bgresponse', 'Email', 'Passwd-hidden', 'next']
2018-11-11 10:09:10,069 - urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "POST /signin/v1/lookup HTTP/1.1" 200 None
2018-11-11 10:09:15,571 - hangups.auth - INFO - Submitting form on page 'https://accounts.google.com/signin/v1/lookup'
2018-11-11 10:09:15,571 - hangups.auth - INFO - Page contains forms: ['gaia_loginform']
2018-11-11 10:09:15,571 - hangups.auth - INFO - Page contains inputs: [None, None, None, None, None, None, None, None, None, None, 'profile-information', 'session-state', '_utf8', 'bgresponse', 'Email-hidden', 'Passwd', 'signIn', None]
2018-11-11 10:09:15,660 - urllib3.connectionpool - DEBUG - https://accounts.google.com:443 "POST /signin/challenge/sl/password HTTP/1.1" 200 None

I then tried to use the API from within python, calling get_auth_stdin('./token.txt').  I get the following exception:
Traceback (most recent call last):
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 345, in _make_token_request
    r.raise_for_status()
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://accounts.google.com/o/oauth2/token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 161, in get_auth
    access_token = _auth_with_refresh_token(session, refresh_token)
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 313, in _auth_with_refresh_token
    res = _make_token_request(session, token_request_data)
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 347, in _make_token_request
    raise GoogleAuthError('Token request failed: {}'.format(e))
hangups.auth.GoogleAuthError: Token request failed: 400 Client Error: Bad Request for url: https://accounts.google.com/o/oauth2/token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 294, in _get_authorization_code
    return browser.get_cookie('oauth_code')
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 252, in get_cookie
    return self._session.cookies[name]
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/requests/cookies.py", line 328, in __getitem__
    return self._find_no_duplicates(name)
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/requests/cookies.py", line 399, in _find_no_duplicates
    raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='oauth_code', domain=None, path=None"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 188, in get_auth_stdin
    return get_auth(CredentialsPrompt(), refresh_token_cache)
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 166, in get_auth
    session, credentials_prompt
  File "/home/sarober/hangups/python/lib/python3.5/site-packages/hangups/auth.py", line 296, in _get_authorization_code
    raise GoogleAuthError('Authorization code cookie not found')
hangups.auth.GoogleAuthError: Authorization code cookie not found

Any thoughts on this?  Seems like the URL is bad?

Closing comment (2018-11-11T18:31:16Z): Possibly related to #350 (comment) -- running the manual login flow from a browser with JS disabled now leads me to a captcha + re-enter password screen.