picklepete / pyicloud

A Python + iCloud wrapper to access iPhone and Calendar data.
MIT License
2.45k stars 437 forks source link

Maintain 2fa validation after restart? #409

Closed dathbe closed 10 months ago

dathbe commented 1 year ago

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

Traceback/Error logs

n/a

Checklist

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.

kovaacs commented 1 year ago

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("name@icloud.com", "password", "~/cookies/go/here")

dathbe commented 10 months ago

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.