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

urllib3.util.ssl_ has no attribute DEFAULT_CIPHERS #142

Closed
5 tasks done
danjenson opened this issue May 29, 2023 · 6 comments
Closed
5 tasks done

urllib3.util.ssl_ has no attribute DEFAULT_CIPHERS #142

danjenson opened this issue May 29, 2023 · 6 comments
Labels

Comments

@danjenson
Copy link

danjenson commented May 29, 2023

Please make sure you've done the following before submitting your issue:

  • Check that you're running the newest version of the library.
  • If you're providing a stack trace, make sure it doesn't contain your password.
  • If you're getting a KeyError or ParseException, please follow the instructions here to dump the raw data.

Additionally, please provide the following information:

  • Operating system : Void LInux
  • Python version : 3.11
#!/usr/bin/env python3
import argparse
import sys
from pathlib import Path

import gkeepapi
import keyring
import yaml


def main(args):
    keep = gkeepapi.Keep()
    with open(Path(args.credentials_path).expanduser()) as f:
        d = yaml.safe_load(f)
    keep.login(d["username"], d["password"])


def parse_args(argv):
    parser = argparse.ArgumentParser(
        prog=argv[0],
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument('-c', '--credentials_path', default='~/.keys/google.yaml')
    return parser.parse_args(argv[1:])


if __name__ == "__main__":
    args = parse_args(sys.argv)
    main(args)

Stack trace:

λ python keep.py
Traceback (most recent call last):
  File "/data/scratch/keep.py", line 28, in <module>
    main(args)
  File "/data/scratch/keep.py", line 15, in main
    keep.login(d["username"], d["password"])
  File "/home/danj/.local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 697, in login
    ret = auth.login(email, password, device_id)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danj/.local/lib/python3.11/site-packages/gkeepapi/__init__.py", line 54, in login
    res = gpsoauth.perform_master_login(self._email, password, self._device_id)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danj/.local/lib/python3.11/site-packages/gpsoauth/__init__.py", line 143, in perform_master_login
    return _perform_auth_request(data, proxy)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danj/.local/lib/python3.11/site-packages/gpsoauth/__init__.py", line 78, in _perform_auth_request
    session.mount(AUTH_URL, AuthHTTPAdapter())
                            ^^^^^^^^^^^^^^^^^
  File "/home/danj/.local/lib/python3.11/site-packages/requests/adapters.py", line 155, in __init__
    self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)
  File "/home/danj/.local/lib/python3.11/site-packages/gpsoauth/__init__.py", line 68, in init_poolmanager
    context.set_ciphers(ssl_.DEFAULT_CIPHERS)
                        ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'urllib3.util.ssl_' has no attribute 'DEFAULT_CIPHERS'

It looks like urllib3 no longer defines this, which is used by gpsoauth. Unclear what the cleanest way to repair / mediate this going forward is, as it seems we need to specify a cipher in order for google to permit logins. I manually modified the gpsoauth package to put the DEFAULT_CIPHERS back in but still got (BadAuthentication, None) error.

@abeisleem
Copy link

Reverting to the following library to an older version helped for me:
pip3 install requests==2.23.0
It's certainly not a ideal solution but it may fit your needs.

@danjenson
Copy link
Author

Thanks! Although, I think it is important to properly set the cipher or have a reasonable default going forward, and I'm not sure what makes the most sense for this library/API.

@listerr
Copy link

listerr commented Jun 25, 2023

I encountered the same error (urllib3.util.ssl_ has no attribute DEFAULT_CIPHERS).

Tried this and also downgrading urllib to 1.25.11 as suggested elsewhere, but now I get:

robl@:~/venv_test$ ./foo.py
Traceback (most recent call last):
  File "/home/robl/venv_test/./foo.py", line 8, in <module>
    success = keep.login('username', 'XXXX')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/robl/venv_test/lib/python3.11/site-packages/gkeepapi/__init__.py", line 697, in login
    ret = auth.login(email, password, device_id)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/robl/venv_test/lib/python3.11/site-packages/gkeepapi/__init__.py", line 62, in login
    raise exception.LoginException(res.get("Error"), res.get("ErrorDetail"))
gkeepapi.exception.LoginException: ('BadAuthentication', None)
robl@:~/venv_test$ ./bin/pip list
Package            Version
------------------ --------
certifi            2023.5.7
cffi               1.15.1
chardet            3.0.4
charset-normalizer 3.1.0
cryptography       41.0.1
future             0.18.3
gkeepapi           0.14.2
gpapi              0.4.4
gpsoauth           1.0.2
idna               2.10
pip                23.0.1
protobuf           4.23.3
pycparser          2.21
pycryptodomex      3.18.0
requests           2.23.0
setuptools         66.1.1
urllib3            1.25.11

Any hints?

@jdegregorio
Copy link

I'm experiencing the same issue.

@jkitching
Copy link
Contributor

The DEFAULT_CIPHERS issue looks like it has been fixed here:
simon-weber/gpsoauth#52

For those of you who have downgraded to urllib3==1.26.16 and are getting BadAuthentication errors, that is a separate issue:
simon-weber/gpsoauth#48

openssl3 doesn't work... so I wrote a small Dockerfile to take care of getting a master token. After you have a master token, you can use other functionality with openssl3 without worrying about the BadAuthentication error.
simon-weber/gpsoauth#48 (comment)

@kiwiz kiwiz added the bug label Sep 21, 2023
@kiwiz
Copy link
Owner

kiwiz commented Jan 19, 2024

Closing since the issue is now resolved.

@kiwiz kiwiz closed this as completed Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants