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

2FA using IMAP stopped working #69

Open
scottmil opened this issue Jul 4, 2021 · 8 comments
Open

2FA using IMAP stopped working #69

scottmil opened this issue Jul 4, 2021 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@scottmil
Copy link

scottmil commented Jul 4, 2021

I discovered today that logging into Arlo with 2FA IMAP suddenly stopped working after months of successful logins. I use my Gmail account and an app password that I assume is still valid. 2FA failed with both 0.8.0a5 and 0.8.0a6 installed.
(BTW: Thanks so much keeping this code working with Arlo!)

I run pyaarlo on a Raspberry Pi with uWSGI and connect to Hubitat using asynchronous HTTP GET requests. Below is the log of starting up uWSGI:

*** Starting uWSGI 2.0.19.1 (32bit) on [Sun Jul 4 13:06:23 2021] ***
compiled with version: 8.3.0 on 17 June 2020 09:19:11
os: Linux-4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020
nodename: arlo-pi
machine: armv7l
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /home/pi
detected binary path: /usr/local/bin/uwsgi
chdir() to /home/pi/webapp/
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7336
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:8000 fd 3
Python version: 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
Python main interpreter initialized at 0x17acdf8
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 64408 bytes (62 KB) for 1 cores
*** Operational MODE: single process ***
2021-07-04 13:06:24,880 - pyaarlo - INFO - pyarlo 0.8.0a6 starting...
2021-07-04 13:06:24,881 - pyaarlo - WARNING - Problem creating aarlo
2021-07-04 13:07:56,432 - pyaarlo - ERROR - 2fa core retrieval failed
failed to login(2fa core retrieval failed)

@scottmil
Copy link
Author

scottmil commented Jul 4, 2021

I disabled IMAP 2FA and instead configured console 2FA using this login:

arlo = pyaarlo.PyArlo(username=USERNAME, password=PASSWORD, tfa_source='console', tfa_type='SMS', storage_dir='aarlo', verbose_debug=True)

but I got the errors below when starting up uWSGI with pyarlo 0.8.0a6. Arlo did manage to return an authentication code on my iPhone.
...

uwsgi socket 0 bound to TCP address 0.0.0.0:8000 fd 3
Python version: 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
Python main interpreter initialized at 0x20dcdf8
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 64408 bytes (62 KB) for 1 cores
*** Operational MODE: single process ***
2021-07-04 14:35:23,371 - pyaarlo - INFO - pyarlo 0.8.0a6 starting...
Enter Code: Traceback (most recent call last):
File "./arloApp.py", line 38, in
arlo = pyaarlo.PyArlo(username=USERNAME, password=PASSWORD, tfa_source='console', tfa_type='SMS', storage_dir='aarlo', verbose_debug=True)
File "/home/pi/.local/lib/python3.7/site-packages/pyaarlo/init.py", line 159, in init
self._be = ArloBackEnd(self)
File "/home/pi/.local/lib/python3.7/site-packages/pyaarlo/backend.py", line 63, in init
self._logged_in = self._login()
File "/home/pi/.local/lib/python3.7/site-packages/pyaarlo/backend.py", line 677, in _login
if not self._auth():
File "/home/pi/.local/lib/python3.7/site-packages/pyaarlo/backend.py", line 587, in _auth
code = tfa.get()
File "/home/pi/.local/lib/python3.7/site-packages/pyaarlo/tfa.py", line 23, in get
return input("Enter Code: ")
EOFError: EOF when reading a line
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
spawned uWSGI worker 1 (and the only) (pid: 645, cores: 1)

@scottmil
Copy link
Author

scottmil commented Jul 4, 2021

Please close this issue. 2FA using IMAP is working again. Not sure what the problem was. I fixed the warning I was getting by creating the storage_dir "aarlo" which I had omitted.

@scottmil scottmil closed this as completed Jul 4, 2021
@twrecked
Copy link
Owner

twrecked commented Jul 4, 2021

Perfect timing, I was just about to reply.

I added token caching and it needs a directory to store that information, I guess I need to make that code more robust. I'll also improve the docs for this piece.

And the token caching means it should only generate the 2FA email once every 14 days. If it causes you problems you can turn it off with the save_session=False option.

@scottmil
Copy link
Author

scottmil commented Jul 4, 2021 via email

@scottmil
Copy link
Author

scottmil commented Jul 4, 2021

Ahh....when I included save_session=False in my login, it worked:

*** Operational MODE: single process ***
2021-07-04 15:29:21,377 - pyaarlo - INFO - pyarlo 0.8.0a6 starting...
2021-07-04 15:29:35,161 - pyaarlo - INFO - pyaarlo starting
WSGI app 0 (mountpoint='') ready in 19 seconds on interpreter 0x1889df8 pid: 658 (default app)
spawned uWSGI worker 1 (and the only) (pid: 658, cores: 1)
[pid: 658|app: 0|req: 1/1] 192.168.0.153 () {28 vars in 351 bytes} [Sun Jul 4 15:29:59 2021] GET / => generated 62 bytes in 47 msecs (HTTP/1.1 200) 2 headers in 79 bytes (1 switches on core 0)
[pid: 658|app: 0|req: 2/2] 192.168.0.153 () {28 vars in 351 bytes} [Sun Jul 4 15:29:59 2021] GET / => generated 62 bytes in 3 msecs (HTTP/1.1 200) 2 headers in 79 bytes (1 switches on core 0)

@scottmil scottmil reopened this Jul 4, 2021
@twrecked
Copy link
Owner

twrecked commented Jul 5, 2021

Thanks for the update. I'll double check the authentication operation here.

@twrecked twrecked self-assigned this Jul 5, 2021
@twrecked twrecked added the bug Something isn't working label Jul 5, 2021
@twrecked
Copy link
Owner

twrecked commented Jul 5, 2021

It's working here for me.

If you get a chance do you mind trying it again with pyaarlo debug enabled. You can add verbose_debug=True to the PyArlo options and turn on DEBUG level logging (I don't know how to do that with the software you are using).

One final question, are you using Arlo in English or another language?

edit: you can ignore that last question, it's working when you don't save the session so I don't think there is an issue reading the code from the emails.

@scottmil
Copy link
Author

scottmil commented Jul 5, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants