wandera / 1password-client

Python wrapper for OnePassword CLI developed at Wandera.
MIT License
47 stars 25 forks source link

Unexpected error during login first time #22

Closed tourl closed 3 years ago

tourl commented 3 years ago

Hello, I'm using for first time this module and looks awesome, currently I'm trying to login to 1 password and I'm receiving this error, I tried using the cli directly and it connects with no problem, any idea? I don't know if it's a bug or I'm doing something wrong:

python 3.9.4
Mac OS 11.3.1 Intel 

Please input your email address used for 1Password account: david.hernandez1@domain.com Is your 1Password domain: domain.1password.com (y/n)? n Please input your 1Password domain in the format .1password.com: domain.ent.1password.com Is your 1Password account name: domain (y/n)? n Please input your 1Password account name e.g. wandera from wandera.1password.com: NAME Please input your 1Password secret key: Please input your 1Password master password: Traceback (most recent call last):


Traceback (most recent call last):
  File "/Users/davidhernandez/Documents/ies-local/utilities/one_password_util.py", line 4, in <module>
    op = OnePassword()
  File "/usr/local/lib/python3.9/site-packages/onepassword/client.py", line 40, in __init__
    self.first_use()
  File "/usr/local/lib/python3.9/site-packages/onepassword/client.py", line 72, in first_use
    self.signin_wrapper(account, signin_domain, email_address, secret_key)
  File "/usr/local/lib/python3.9/site-packages/onepassword/client.py", line 99, in signin_wrapper
    password, session_key, domain, account, bp = self._signin(account, domain, email, secret_key, master_password)
  File "/usr/local/lib/python3.9/site-packages/onepassword/client.py", line 168, in _signin
    sess_key = _spawn_signin(op_command, master_password)
  File "/usr/local/lib/python3.9/site-packages/onepassword/utils.py", line 68, in _spawn_signin
    child.expect([master_password_regex, pexpect.EOF])
  File "/usr/local/lib/python3.9/site-packages/pexpect/spawnbase.py", line 343, in expect
    return self.expect_list(compiled_pattern_list,
  File "/usr/local/lib/python3.9/site-packages/pexpect/spawnbase.py", line 372, in expect_list
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.9/site-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)
  File "/usr/local/lib/python3.9/site-packages/pexpect/expect.py", line 144, in timeout
    raise exc
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x1095c4070>
command: /usr/local/bin/op
args: ['/usr/local/bin/op', 'signin', 'domain.ent.1password.com', 'david.hernandez1@domain.com', 'MY-SECRET-KEY', '--raw', '--shorthand', 'NAME']
buffer (last 100 chars): b'Enter the password for david.hernandez1@domain.com at domain.ent.1password.com: '
before (last 100 chars): b'Enter the password for david.hernandez1@domain.com at domain.ent.1password.com: '
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 53745
child_fd: 5
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile(b'Enter the password for [a-zA-Z0-9._%+-]+\\@[a-zA-Z0-9-]+\\.[a-zA-z]{2,4} at [a-zA-Z0-9-]+\\.[a-zA-Z0-9-]+\\.[a-zA-z]{2,4}')
    1: EOF
dtpryce commented 3 years ago

Might be a bug ... So your account domain is made up of two subdomains? That appears to be part of the problem.

dtpryce commented 3 years ago

Can you write here what you gave the cli? No secrets of course!

tourl commented 3 years ago

Thanks for your answer @dtpryce this is what I gave to the cli

Please input your email address used for 1Password account: david.hernandez1@domain.com
Is your 1Password domain: domain.1password.com (y/n)? n
Please input your 1Password domain in the format .1password.com: domain.ent.1password.com
Is your 1Password account name: domain (y/n)? n
Please input your 1Password account name e.g. wandera from wandera.1password.com: NAME
Please input your 1Password secret key: MY-SECRET-KEY
Please input your 1Password master password: myMasterPassword
dtpryce commented 3 years ago

That's what you gave to the client ... I meant what did you input with op signin ... directly ... My bad for confusion.

tourl commented 3 years ago

oh yep, I gave same as the logged command just without commas op signin https://domain.ent.1password.com david.hernandez1@domain.com MY-SECRET-KEY --raw --shorthand NAME

dtpryce commented 3 years ago

Great will try to use those to debug!! Thanks

dtpryce commented 3 years ago

Sorry for late reply but we have got around to these various issues this week. What you should see in the next release is an update for the regex that will catch your logins and all others correctly plus extended the timeout just in case people take a little longer to input things.

🤞🏼 it should all be fine, so keep your eyes open for a newer version :)

tourl commented 3 years ago

Awesome! I'll wait for it, thank you!

dtpryce commented 3 years ago

If you want to try early it should be on this branch https://github.com/wandera/1password-client/tree/pre-installed-op and you can install locally using pip install -e . or python setup.py install ... otherwise wait for the new version and test there

dtpryce commented 3 years ago

Fixed in #29