Maintain 2fa validation after restart?
The problem
The first time I run my script, it requires 2fa (as expected).
Every subsequent time I run my script without restarting, it does not require additional 2fa (as expected).
But when I restart the device, the script requires a new 2fa (not as expected).
Once the device has been validated with 2fa, is there a way to save the validation so that it can be reused after restart?
Environment
- pyiCloud release with the issue (
pip show pyicloud): 1.0.0 - Last working pyiCloud release (if known): 1.0.0
- Service causing this issue: api.requires_2fa
- Python version (
python -V): 3.9.2 - Operating environment (project deps/Docker/Windows/etc.): Debian 11 (Bullseye)
Traceback/Error logs
n/a
Checklist
- [x ] I've looked informations into the README.
- [x ] I've looked informations into the pyiCloud's code.
- [x ] I've looked informations in Google.
Additional information
I don't think this is a bug. It's just a question about how the software works. If it is not possible to persist a 2fa authentication beyond a restart, that's fine, but if there is a way to store a cookie or credentials or something to pass to the script, I'd like to do so.
From my understanding, you need to specify a custom folder for the cookies if you want them to persist as the default is a temporary directory which is purged by the OS after restart, e.g. api = PyiCloudService("[email protected]", "password", "~/cookies/go/here")
I was traveling when this solution was posted, so I didn't see it until just now. But I believe it does do the trick. Thanks very much.