mandarons / icloud-docker

Dockerized iCloud Client - make a local copy of your iCloud documents and photos, and keep it automatically up-to-date.
BSD 3-Clause "New" or "Revised" License
1.15k stars 49 forks source link

[BUG] Keyring never seen as saved - ERROR :: root :: sync.py :: 116 :: Password is not stored in keyring. Please save the password in keyring. #238

Closed TheCase closed 2 months ago

TheCase commented 4 months ago

I know this is a duplicate of the previous report, but am filing separately as that issue is awaiting a response. I am using the new /config directory layout for local config and session_data storage (as seen in the included docker-compose and config file)

Describe the bug The authentication information is not correctly stored in the keyring, according to the app

App was working fine before the recent updates. Love the app. So dearly want it to be working again!

Platform: Synology NAS

To Reproduce

  1. delete all session data in ./config
  2. docker-compose up -d
  3. log in using following command (outside docker container):
  4. docker exec -it icloud /bin/sh -c "icloud --username=actualusername@mac.com --session-directory=/config/session_data"
  5. answer "y" to save keyring prompt
  6. enter TFA
  7. assume that nothing returned means login was successful
  8. either a) wait 10 minutes or b) stop container and restart
  9. see error "Password is not stored in keyring"

Expected behavior keyring save should result in successful login

Configuration docker-compose.yaml

version: "3.4"
services:
  iCloud:
    container_name: icloud
    image: mandarons/icloud-drive:latest
    environment:
      - PUID=1000
      - GUID=1000
      - ENV_CONFIG_FILE_PATH=/config/config.yaml
      - TZ=America/Boise
    volumes:
      - ./config:/config
      - ./icloud:/icloud

I've also set the config to have logs at debug level. I don't see debug level logs. I know the config is somewhat working, as the Discord notifications about TFA requirements are working

./config/config.yaml:

app:
  logger:
    level: "debug"
    filename: "/config/icloud.log"
  credentials:
    username: "actualusername@mac.com"
    retry_login_interval: 600
  root: "/icloud"
  discord:
    webhook_url: https://discord.com/api/webhooks/XXXwebookidXXX
    username: iCloud-Files
  region: global
drive:
  destination: "drive"
  remove_obsolete: false
  sync_interval: 600
photos:
  destination: "photos"
  remove_obsolete: false
  sync_interval: 300
  all_albums: true 
  folder_format: "%Y/%m" 
  filters:
    file_sizes:
      - "original"
TheCase commented 4 months ago

I'll add that subsequent attempts to authenticate do not prompt for password - just exits code 0.

mandarons commented 4 months ago

Try setting the ENV_ICLOUD_PASSWORD variable.

jmsaham commented 4 months ago

Same issue. Adding the ENV_ICLOUD_PASSWORD variable to Docker container does nothing. I have it setup with Telegram. I get the notification to run the Auth command, since the variable is set it doesn't ask me for a password, and then I enter the 2FA code, it takes me back to a prompt.

2024-07-05 21:07:58,417 :: INFO :: icloudpy.base :: base.py :: 253 :: Session file does not exist 2024-07-05 21:07:59,567 :: ERROR :: root :: sync.py :: 100 :: Error: 2FA is required. Please log in. 2024-07-05 21:07:59,567 :: INFO :: root :: config_parser.py :: 69 :: Retrying login every 600 seconds. 2024-07-05 21:07:59,567 :: INFO :: root :: sync.py :: 109 :: Retrying login at Fri Jul 5 21:17:59 2024 ...

TheCase commented 3 months ago

I have also tried the ENV_ICLOUD_PASSWORD variable. Still no luck

rix1337 commented 3 months ago

Yep. Also still broken here.

gniting commented 3 months ago

I was having the same issue and adding the ENV_ICLOUD_PASSWORD env variable fixed it for me.

rix1337 commented 3 months ago

Not for me. I am using that exact var.

gniting commented 3 months ago

@rix1337 Onboarding is not smooth, I give you that. I've had to find my way to various trials and errors to get the latest version to run properly. The latest release(s) have made some underlying changes that are most likely the cause of the confusion.

The other problem I am running into is this. Not a big deal, but it's not "clean." This never happened before the latest releases either. Are you seeing the same?

rix1337 commented 3 months ago

Agreed. The docker was working for months. The recent changes broke it with the above error. The new ENV does not help, even when used.

jyourstone commented 3 months ago

Same issue here, keep getting the error "Password is not stored in keyring. Please save the password in keyring." on reboot. If I add the ENV variable ENV_ICLOUD_PASSWORD I get a TFA push notification from Apple on reboot. If I manually remove the password from keyring and login again everything seems fine in the console, but the errors are still there.

gniting commented 3 months ago

I also noticed that the init script makes a directory called session under /config but the code and examples reference a directory called session_data. So I made session a symlink to session_data, emptied the directory and started with a new login. Seems to have worked.

At this point, I am just shooting in the dark and hoping something sticks! 🙂

Let's wait for @mandarons to share guidance.

rix1337 commented 3 months ago

Sounds like that’s the bug

rix1337 commented 3 months ago

I debugged this project and found the issue.

Do not run icloud --session-directory=/app/session_data --username=foo@b.ar --> this dir is not referenced at all Run this instead icloud --session-directory=/config/session_data --username=foo@b.ar

jyourstone commented 3 months ago

I debugged this project and found the issue.

Do not run icloud --session-directory=/app/session_data --username=foo@b.ar --> this dir is not referenced at all Run this instead icloud --session-directory=/config/session_data --username=foo@b.ar

That worked, thank you!

rix1337 commented 3 months ago

@mandarons the current docket build notifications reference a wrong dir

mandarons commented 3 months ago

Sorry folks for delayed response here. Life has been busy lately.

I fixed 2 of the issues mentioned here (#245 and #246). It looks like documentation is also up to date with changes for using /config/session_data path (instead of /app/session_data).

Please give it a try with mandarons/icloud-drive:main tag and let me know if you still see any issues.

nicx commented 3 months ago

@mandarons I updated yesterday to the last version. With this version I'll get the 2FA Apple prompt every hour.

But I have already executed the command "docker exec -it icloud-docker /bin/sh -c "icloud --username=*** --session-directory=/app/session_data"" and filled in the Auth code once. Repeating that commend does not show any missing info, so I'll get no output anymore.

So this is unfortunately still not working! :(

This is the log:

2024-07-22 11:43:57,770 :: ERROR :: icloudpy.base :: base.py :: 186 :: Authentication required for Account. (421)
2024-07-22 11:43:59,306 :: ERROR :: root :: sync.py :: 100 :: Error: 2FA is required. Please log in.
mandarons commented 3 months ago

@nicx : Please use /config/session_data instead of /app/session_data and try again.

nicx commented 3 months ago

@mandarons shit, that was my mistake. thanks for your hint! I just used the old command from an old mail :)

TheCase commented 3 months ago

I got a chance to try the latest "main" tag today, seeing this error:

Starting icloud ... done
Attaching to icloud
icloud    | s6-rc-compile: fatal: unable to open /etc/s6-overlay/s6-rc.d/svc-icd/up: No such file or directory
mandarons commented 3 months ago

@TheCase please try again. I added the missing file. It seems to be working on my system.

TheCase commented 3 months ago

Ok. That worked...

But only when ENV_ICLOUD_PASSWORD is defined. This was not a requirement before the latest changes (where you moved config assets from /app to /config).

I would prefer not to hard core my iCloud password in a file or provide it to the docker environment (where it is visible in the docker inspect output of the container).

Unfortunately, this is still a bug. Auth was working fine without the var, previously.

That said, I have a feeling you do this in your free time. I very much appreciate the effort you made to get this app working for several of us!

mandarons commented 2 months ago

@TheCase: Completely agree with you about recent hard requirement of ENV_ICLOUD_PASSWORD. Please try the following steps and let me know if that works (it seem to be working for me).

  1. Remove ENV_ICLOUD_PASSWORD variable
  2. Use docker exec -it --user=abc icloud /bin/sh -c "icloud --username=<icloud-username> --session-directory=/config/session_data" to save icloud password in keyring. (Note the use of --user=abc option in docker exec command).

Please let me know if it works. I will update the documentation accordingly.

TheCase commented 2 months ago

Indeed, that --user add was the trick!

Please note that this did not work until I deleted any existing session data from the /config volume.

Thank you! This is perfect. Cheers!

mandarons commented 2 months ago

I will update the docs to indicate ENV_ICLOUD_PASSWORD is optional (again). Thanks for quickly testing it.