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

Help Request: 2fa and maintaining a login for at least 24 hours #431

Open
stevenmcastano opened this issue Jun 27, 2023 · 1 comment
Open

Comments

@stevenmcastano
Copy link

The problem

I'm working on a python application that will connect to the icloud API and read some stats about my device, log in to be displayed in grafana and take actions, home automation tasks, time to check again next, etc... based on the data I get back. One of the things I'm doing is not updating my position as frequently when I'm farther from home. Sometimes this can mean 16+ hours between location lookups...

This is where the problem is... every single time I connect back to the API, it seems to trigger another login and approval. Does anybody have a code sample/suggestion that I could follow that would help me connect to the API and somehow hold the session for a while, hopefully an extended period of time if I'm only doing one lookup every few hours.

Environment

  • pyiCloud release with the issue (pip show pyicloud):
    Name: pyicloud
    Version: 1.0.0
  • Python version (python -V):
    Python 3.11.3
  • Operating environment (project deps/Docker/Windows/etc.):
    Docker python3 container
@opfpqgoon
Copy link

If you authenticate on the cli with icloud --username appleid@domain this will store a session file at /tmp/pyicloud/computerusername/cookies/.session

Any use of the module after the above authentication will look for this session file (if you use the same apple ID in your code)

As long as that session file exists, you shouldn't be prompted for authentication. You can alternatively specify the session path with api = PyiCloudService(apple_id=appleid@domain, cookie_directory=/path/to/cookie/dir to store the cookies and session file at a different path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants