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

[BUG] Error: 2FA is required. Please log in. #278

Closed
anfractuosity opened this issue Dec 8, 2024 · 10 comments
Closed

[BUG] Error: 2FA is required. Please log in. #278

anfractuosity opened this issue Dec 8, 2024 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@anfractuosity
Copy link

anfractuosity commented Dec 8, 2024

Describe the bug

I thought this may have possibly been fixed as I saw recent changes to both icloudpy and icloud-docker, however, I still appear
to get a 2FA error.

To Reproduce

docker-compose pull
docker-compose up
icloud  | 2024-12-08 14:44:41,571 :: ERROR :: icloudpy.base :: base.py :: 180 :: Authentication required for Account. (421)
icloud  | 2024-12-08 14:44:43,509 :: ERROR :: root :: sync.py :: 87 :: Error: 2FA is required. Please log in.

I get a passcode notification on the iphone when running docker-compose up

And then use:

docker exec -it icloud /bin/sh -c "icloud --username=<EMAIL> --session-directory=/app/session_data"

I've noticed sometimes this doesn't even seem to prompt for a code, so am a bit confused.

I then wait for it to re-try logging in, I set to 180s. It then seems to give me another code on my phone.

But when I use the 2fa command, it doesn't give a prompt to enter the code.

Expected behavior
No 2FA error

Configuration
I use the following docker-compose.yml:

services:
  icloud:
    image: mandarons/icloud-drive
    environment:
      - PUID=1000
      - GUID=1000
    env_file:
      - .env.icloud #should contain ENV_ICLOUD_PASSWORD=<password>
    container_name: icloud
    restart: unless-stopped
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - ${PWD}/config.yaml:/app/config.yaml
      - ${PWD}/icloud/data:/app/icloud
      - ${PWD}/session_data:/app/session_data
@anfractuosity anfractuosity added the bug Something isn't working label Dec 8, 2024
@patmuk
Copy link

patmuk commented Dec 13, 2024

You have to change /app/session-data to /config/session-data.

Not sure if it is hard-coded

or the variable works - DEFAULT_COOKIE_DIRECTORY

... but it is easiest to remove
- ${PWD}/session_data:/app/session_data from your docker-compose.yaml and

use
docker exec -it icloud /bin/sh -c "icloud --username=<EMAIL> --session-directory=/config/session_data"
instead of
docker exec -it icloud /bin/sh -c "icloud --username=<EMAIL> --session-directory=/app/session_data"

@anfractuosity
Copy link
Author

Thank you so much for your help, @patmuk , that works :)
One thing I'm slightly confused by, in the docker compose in the docks it says

      - ${PWD}/config:/config # Must contain config.yaml

(which seemed to give me an apple_id error in icloudpy)

I seem to have to use:

     - ${PWD}/config/config.yaml:/app/config.yaml

@patmuk
Copy link

patmuk commented Dec 13, 2024

You are very welcome :)

For me that setting works ... I made the path explicit - but that shouldn't matter. Made this while trying to get it work.

- /volume2/docker/iCloud-buper/config:/config # Must contain config.yaml

When I log into the docker machine (docker exec -it icloud-buper bash) I can see all files in /config/ - meaning the config.yaml and the session_data folder. My apple-id is defined in the config.yaml (

    # iCloud drive username
    username: "<[email protected]"
    ```
When I authenticated with `docker exec -it icloud-buper /bin/sh -c "icloud --username=<EMAIL> --session-directory=/config/session_data"` I stored the password in the keychain.

(Note that I named my docker container ìcloud-buper` - which doesn't matter.)

Hope that helps - let me know if not!

@anfractuosity
Copy link
Author

anfractuosity commented Dec 13, 2024

Interesting, so I used that docker exec command, I can see the session_data in /config. But I see a number of files in /app - config.yaml, init.sh, ..

Maybe I didn't destroy the container properly I'm wondering to then re-create.

Thanks a lot for the help! I'll have a play and close this now, it's syncing photos great now :)

@patmuk
Copy link

patmuk commented Dec 13, 2024

The init.sh, etc, is normal. These are the files & folders I have in /app/:

CODE_OF_CONDUCT.md  LICENSE    USAGE.md     generate_badges.py	init.sh		  root	     run-in-env.sh  unraid
Dockerfile-debug    README.md  config.yaml  gpg-init.sh		requirements.txt  run-ci.sh  src

I assume everything else (e.g. /app/session_data) is a leftover.

Interesting is the /app/config.yaml! However, looking into the file for me it is just the template (e.g. with username: "[email protected]").

I think fastest way to clean up is cleaning and re-building the docker image. The authentication token is in the session_data folder, so everything should continue to work.

@anfractuosity
Copy link
Author

Is docker compose down enough to destroy it, or do I need to use another command maybe?
I'm not terribly used to docker.

@anfractuosity
Copy link
Author

anfractuosity commented Dec 13, 2024

Oh, I think I worked out why placing the config.yml in /config didn't work for me.

I just see this note:

      - .env.icloud
      # Must contain ENV_CONFIG_FILE_PATH=/config/config.yaml and optionally, ENV_ICLOUD_PASSWORD=<password>

I didn't have ENV_CONFIG_FILE_PATH defined

@patmuk
Copy link

patmuk commented Dec 13, 2024

No worries :)
No, docker-compose down is just stopping the container. Basically you are starting with a docker description, the docker-compose.yaml. docker-compose up creates a docker image out of it (composed of some downloaded pre-existing images and the specific changes specified in the compose.yaml) and creates a docker container, which is the virtual machine started (it is a linux-jail, not a vm - but that doesn't matter here).
This docker container is only stopped with docker-compose down and keeps its state.

In order to cleanup, you need to docker rm <ID of your container, I assume iCloud>.

You can read about that here. I wrote that out of my memory, might be wrong or oversimplifying some things.

@patmuk
Copy link

patmuk commented Dec 13, 2024

Oh, I think I worked out why placing the config.yml in /config didn't work for me.

I just see this note:

      - .env.icloud
      # Must contain ENV_CONFIG_FILE_PATH=/config/config.yaml and optionally, ENV_ICLOUD_PASSWORD=<password>

I didn't have ENV_CONFIG_FILE_PATH defined

Ah, that is possible! My .env.icloud file is next to the docker-compose.yaml file and contains:
``cat .env.icloud
ENV_CONFIG_FILE_PATH=/config/config.yaml```

@anfractuosity
Copy link
Author

Thanks a lot! Will read your link too about docker rm.

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

3 participants