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 during 2FA authentification #78

Closed
xiaotianxt opened this issue May 6, 2022 · 15 comments · Fixed by #82
Closed

[BUG] Error during 2FA authentification #78

xiaotianxt opened this issue May 6, 2022 · 15 comments · Fixed by #82
Assignees
Labels
bug Something isn't working Stale
Milestone

Comments

@xiaotianxt
Copy link

Describe the bug
After execting the login command given in README.md

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

The following error shows:

tian@dorm-synology:/volume1/docker/icloud-drive$ sudo docker exec -it icloud /bin/sh -c "icloud --username=testtest@testtest.com --session-directory=/app/session_data"
Enter iCloud password for testest@testtest.com:
Traceback (most recent call last):
  File "/app/venv/bin//icloud", line 8, in <module>
    sys.exit(main())
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 207, in main
    api = ICloudPyService(
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 273, in __init__
    self.authenticate()
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 344, in authenticate
    self._webservices = self.data["webservices"]
KeyError: 'webservices'

To Reproduce
Steps to reproduce the behavior:

  1. Execute the command above.
  2. See error

Configuration
If applicable, please share the configuration details

docker-compose.yaml:

version: "3.4"
services:
  icloud:
    image: mandarons/icloud-drive
    environment:
      - PUID=1026
      - GUID=100
    env_file:
      - /volume1/docker/icloud-drive/.env.icloud
    container_name: icloud
    restart: unless-stopped
    volumes:
      - /volume1/docker/icloud-drive/config.yaml:/app/config.yaml
      - /volume2/Onedrive/icloud:/app/icloud/drive
      - /volume1/docker/icloud-drive/session_data:/app/session_data

config.yaml:

app:
  logger:
    # level - debug, info (default), warning or error
    level: "info"
    # log filename icloud.log (default)
    filename: "icloud.log"
  credentials:
    # iCloud drive username
    username: "testest@testtest.com"
    # Retry login interval - default is 10 minutes
    retry_login_interval: 600
  # Drive destination
  root: "icloud"
  smtp:
    ...
drive:
  destination: "drive"
  remove_obsolete: false
  sync_interval: 300
@xiaotianxt xiaotianxt added the bug Something isn't working label May 6, 2022
@github-actions
Copy link

github-actions bot commented Jun 6, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jun 6, 2022
@mandarons mandarons reopened this Jul 8, 2022
@mandarons
Copy link
Owner

@xiaotianxt is it still a valid bug? Sorry, I didn't get a chance to look at it until now. I am not able to reproduce it.

@iPixelOldC
Copy link

iPixelOldC commented Jul 15, 2022

@xiaotianxt is it still a valid bug? Sorry, I didn't get a chance to look at it until now. I am not able to reproduce it.

yeah, I also encountered this problem. And the pop-up window of 2fa on my mobile phone appeared, but the same error was also reported.
But if you don't appear, I guess it's because Xiao and I both use the Chinese version of iCloud(云上贵州). Maybe that's the problem.
As far as I know, their domain names are different. We use https://www.icloud.com.cn

version: "3.4"
services:
  icloud:
    image: mandarons/icloud-drive
    environment:
      - PUID=1000
      - GUID=1000
    container_name: icloud
    restart: unless-stopped
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /home/zxzx/.config/icloud/config.yaml:/app/config.yaml
      - /home/zxzx/share/icloud/data:/app/icloud
      - /home/zxzx/.config/icloud/session_data:/app/session_data

config.yaml same

/app # icloud --username=*** --session-directory=/app/session_data
Enter iCloud password for ***: 
Traceback (most recent call last):
  File "/app/venv/bin//icloud", line 8, in <module>
    sys.exit(main())
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 207, in main
    api = ICloudPyService(
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 273, in __init__
    self.authenticate()
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 344, in authenticate
    self._webservices = self.data["webservices"]
KeyError: 'webservices'

@mandarons
Copy link
Owner

@iPixelOldC : Yes! Now that makes a lot more sense to me. It looks like iCloud.com.cn has some different structure for iCloud webservices. Do you mind helping me to confirm that? I would like to see a dump of self.data variable shown in the error.

@iPixelOldC
Copy link

@mandarons Sure, what should I do?

And I found icloudpd supports the iCloud CN. Looking at the source code, it just replaces the domain name. Then I use his container. After opening the support, it can work.

@mandarons
Copy link
Owner

  1. Run the following command inside container -
    sed -i -e "s#icloud.com/#icloud.com.cn/#" -e "s#icloud.com'#icloud.com.cn'#" "$(pip show icloudpy | grep "Location" | awk '{print $2}')/icloudpy/base.py"
  2. Then try to reproduce the error again

@iPixelOldC
Copy link

iPixelOldC commented Jul 16, 2022

It seems to work, but it still needs to be modified in one place, otherwise it will report the same webservices error.

sed -i -e "s#icloud.com/#icloud.com.cn/#" -e "s#icloud.com'#icloud.com.cn'#" "$(pip show icloudpy | grep "Location" | awk '{print $2}')/icloudpy/base.py"
cd /app/venv/lib/python3.9/site-packages/icloudpy
vi base.py

then modify HOME_ENDPOINT (I don't know why it hasn't been modified by sed command)

class ICloudPyService(object):                                                   
    """                                                                          
    A base authentication class for the iCloud service. Handles the              
    authentication required to access iCloud services.                           
                                                                                 
    Usage:                                                                       
        from src import ICloudPyService                                          
        icloudpy = ICloudPyService('username@apple.com', 'password')             
        icloudpy.iphone.location()                                               
    """                                                                          
                                                                                 
    AUTH_ENDPOINT = "https://idmsa.apple.com/appleauth/auth"                     
    HOME_ENDPOINT = "https://www.icloud.com"                                  
    SETUP_ENDPOINT = "https://setup.icloud.com.cn/setup/ws/1"

to

class ICloudPyService(object):                                                   
    """                                                                          
    A base authentication class for the iCloud service. Handles the              
    authentication required to access iCloud services.                           
                                                                                 
    Usage:                                                                       
        from src import ICloudPyService                                          
        icloudpy = ICloudPyService('username@apple.com', 'password')             
        icloudpy.iphone.location()                                               
    """                                                                          
                                                                                 
    AUTH_ENDPOINT = "https://idmsa.apple.com/appleauth/auth"                     
    HOME_ENDPOINT = "https://www.icloud.com.cn"                                  
    SETUP_ENDPOINT = "https://setup.icloud.com.cn/setup/ws/1"

It's work. Photos are also starting to download。

/app # icloud --username=xxx --session-directory=/app/session_data
Bad username or password for xxx
Enter iCloud password for xxx: 
Save password in keyring? [y/N]: y

Two-step authentication required. 
Please enter validation code
(string) --> 000000

/app 
2022-07-16 12:09:45,044 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4634.JPG ...

2022-07-16 12:09:48,792 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4633.JPG ...

2022-07-16 12:09:53,130 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4632.JPG ...

2022-07-16 12:09:56,400 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4631.JPG ...

2022-07-16 12:09:57,214 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4630.JPG ...

2022-07-16 12:09:57,660 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4629.JPG ...

2022-07-16 12:09:58,576 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4628.JPG ...

2022-07-16 12:09:59,231 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4627.JPG ...

2022-07-16 12:09:59,625 :: INFO :: root :: sync_photos.py :: 37 :: Downloading /app/icloud/photos/哔哩哔哩/IMG_4626.JPG ...

@mandarons
Copy link
Owner

@iPixelOldC That's a great news! I know how to fix it now. Thank you for helping me identify the root cause. I will create a build for you to test soon.

@mandarons
Copy link
Owner

@iPixelOldC : please try with docker pull mandarons/icloud-drive:main and see if that fixes the issue.

@iPixelOldC
Copy link

iPixelOldC commented Jul 17, 2022

@mandarons same webservices error. But I can use it after repeating the above operation (sed -i -e "s#icl... vi base.py...). This 'region: china' parameter may not be work?

/app # icloud --username=xxx --session-directory=/app/session_data
Enter iCloud password for xxx: 
Traceback (most recent call last):
  File "/app/venv/bin//icloud", line 8, in <module>
    sys.exit(main())
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 226, in main
    else ICloudPyService(
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 277, in __init__
    self.authenticate()
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 348, in authenticate
    self._webservices = self.data["webservices"]
KeyError: 'webservices'
app:
  logger:
    # level - debug, info (default), warning or error
    level: "info"
    # log filename icloud.log (default)
    filename: "icloud.log"
  credentials:
    # iCloud drive username
    username: "xxx"
    # Retry login interval - default is 10 minutes
    retry_login_interval: 600
  # Drive destination
  root: "icloud"
  smtp:
  region: china
drive:
  destination: "drive"
  remove_obsolete: false
  sync_interval: 300
  filters:
    # File filters to be included in syncing iCloud drive content
    folders:
      - "KyBook 3"
      - "Downloads"
      - "文稿"
    file_extensions:
      # File extensions to be included
      - "pdf"
      - "png"
      - "jpg"
      - "jpeg"
photos:
  destination: "photos"
  remove_obsolete: false
  sync_inteval: 500
  filters:
    albums:
      - "Yealico"
      # - "微博"
    file_sizes: # valid values are original, medium and/or thumb
      - "original"
      # - "medium"
      # - "thumb"
version: "3.4"
services:
  icloud:
    image: mandarons/icloud-drive:main
    environment:
      - PUID=1000
      - GUID=1000
    container_name: icloud
    restart: unless-stopped
    volumes:

      - /home/zxzx/.config/icloud2/config.yaml:/app/config.yaml
      - /home/zxzx/share/icloud/data:/app/icloud
      - /home/zxzx/.config/icloud2/session_data:/app/session_data

base.py

    def __init__(
        self,
        apple_id,
        password=None,
        cookie_directory=None,
        verify=True,
        client_id=None,
        with_family=True,
        auth_endpoint="https://idmsa.apple.com/appleauth/auth",
        # For China, use "https://www.icloud.com.cn"
        home_endpoint="https://www.icloud.com.cn",
        # For China, use "https://setup.icloud.com.cn/setup/ws/1"
        setup_endpoint="https://setup.icloud.com.cn/setup/ws/1",
    ):

@mandarons
Copy link
Owner

@iPixelOldC That's weird. I am able to see authentication error when I select 'region: china'. Can you please check if the change in config is reflecting in the container? You can do that by checking the /app/config.yaml inside the container.

@iPixelOldC
Copy link

@mandarons I think so too, it's too strange. I checked the configuration, including the sync script inside the container, and I also checked that it was up to date. Then I also deleted my configuration file and used the configuration file that came with your container, and then went into the container to modify the region, and the same error occurred. Then I went to try using the sed command and then manually change the home_endpoint, and it worked. I'll try again later.

@iPixelOldC
Copy link

iPixelOldC commented Jul 17, 2022

@mandarons same docker compose file

/app # ls
CODE_OF_CONDUCT.md  README.md           icloud              run-ci.sh           venv
Dockerfile-debug    config.yaml         icloud.log          session_data
LICENSE             generate_badges.py  requirements.txt    src
/app # cd session_data/
/app/session_data # ls
***          ***.session
/app/session_data # rm -rf ./*
/app/session_data # ls
/app/session_data # cd ..
/app # ls
CODE_OF_CONDUCT.md  README.md           icloud              run-ci.sh           venv
Dockerfile-debug    config.yaml         icloud.log          session_data
LICENSE             generate_badges.py  requirements.txt    src
/app # vi config.yaml 
----------- Modify default configuration (region and email)
app:
  logger:
    # level - debug, info (default), warning or error
    level: "info"
    # log filename icloud.log (default)
    filename: "icloud.log"
  credentials:
    # iCloud drive username
    username: "***"
    # Retry login interval - default is 10 minutes
    retry_login_interval: 600
  # Drive destination
  root: "icloud"
  smtp:
    # If you want to recieve email notifications about expired/missing 2FA credentials then uncomment
    # email: "sender@test.com"
    # default to is same as email above
    # to: "receiver@test.com"
    # password:
    # host: "smtp.test.com"
    # port: 587
    # If your email provider doesn't handle TLS
    # no_tls: true
  region: china # valid values are - global (default - uses .com) or china (uses .com.cn)
drive:
  destination: "drive"
  remove_obsolete: false
  sync_interval: 300
  filters:
/app # cat config.yaml 
app:
  logger:
    # level - debug, info (default), warning or error
    level: "info"
    # log filename icloud.log (default)
    filename: "icloud.log"
  credentials:
    # iCloud drive username
    username: "***"
    # Retry login interval - default is 10 minutes
    retry_login_interval: 600
  # Drive destination
  root: "icloud"
  smtp:
    # If you want to recieve email notifications about expired/missing 2FA credentials then uncomment
    # email: "sender@test.com"
    # default to is same as email above
    # to: "receiver@test.com"
    # password:
    # host: "smtp.test.com"
    # port: 587
    # If your email provider doesn't handle TLS
    # no_tls: true
  region: china # valid values are - global (default - uses .com) or china (uses .com.cn)
drive:
  destination: "drive"
  remove_obsolete: false
  sync_interval: 300
  filters:
    # File filters to be included in syncing iCloud drive content
    folders:
      - "folder1"
      - "folder2"
      - "folder3"
    file_extensions:
      # File extensions to be included
      - "pdf"
      - "png"
      - "jpg"
      - "jpeg"
photos:
  destination: "photos"
  remove_obsolete: false
  sync_inteval: 500
  filters:
    albums:
      - "album 1"
      - "album2"
    file_sizes: # valid values are original, medium and/or thumb
      - "original"
      # - "medium"
      # - "thumb"
----------- same error
/app # icloud --username=*** --session-directory=/app/session_data
Enter iCloud password for ***: 
Bad username or password for ***
Enter iCloud password for ***: 
Traceback (most recent call last):
  File "/app/venv/bin//icloud", line 8, in <module>
    sys.exit(main())
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 226, in main
    else ICloudPyService(
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 277, in __init__
    self.authenticate()
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 348, in authenticate
    self._webservices = self.data["webservices"]
KeyError: 'webservices'
/app # ls
CODE_OF_CONDUCT.md  README.md           icloud              run-ci.sh           venv
Dockerfile-debug    config.yaml         icloud.log          session_data
LICENSE             generate_badges.py  requirements.txt    src
/app # cd venv/
bin/      include/  lib/      lib64/
/app # cd venv/lib/python3.9/site-packages/icloudpy
/app/venv/lib/python3.9/site-packages/icloudpy # ls
__init__.py    __pycache__    base.py        cmdline.py     exceptions.py  services       utils.py
/app/venv/lib/python3.9/site-packages/icloudpy # vi base.py 
------------- Modify default domain name
def __init__(
        self,
        apple_id,
        password=None,
        cookie_directory=None,
        verify=True,
        client_id=None,
        with_family=True,
        auth_endpoint="https://idmsa.apple.com/appleauth/auth",
        # For China, use "https://www.icloud.com.cn"
        home_endpoint="https://www.icloud.com.cn",
        # For China, use "https://setup.icloud.com.cn/setup/ws/1"
        setup_endpoint="https://setup.icloud.com.cn/setup/ws/1",
    ):
        if password is
--------------
/app/venv/lib/python3.9/site-packages/icloudpy # cd /app/
/app # icloud --username=*** --session-directory=/app/session_data
Enter iCloud password for ***: 
Save password in keyring? [y/N]: y

Two-step authentication required. 
Please enter validation code
(string) --> 000

/app # 
-------- success

log: After the modification it worked, the error was reported because I didn't have this album

Loading config from /app/config.yaml ...

2022-07-17 14:26:26,661 :: INFO :: keyring.backend :: backend.py :: 154 :: Loading Gnome

2022-07-17 14:26:26,836 :: INFO :: keyring.backend :: backend.py :: 154 :: Loading Google

2022-07-17 14:26:26,865 :: INFO :: keyring.backend :: backend.py :: 154 :: Loading Windows (alt)

2022-07-17 14:26:26,912 :: INFO :: keyring.backend :: backend.py :: 154 :: Loading file

2022-07-17 14:26:26,924 :: INFO :: keyring.backend :: backend.py :: 154 :: Loading keyczar

2022-07-17 14:26:26,925 :: INFO :: keyring.backend :: backend.py :: 154 :: Loading multi

2022-07-17 14:26:26,936 :: INFO :: keyring.backend :: backend.py :: 154 :: Loading pyfs

Loading config from /app/config.yaml ...

2022-07-17 14:26:31,069 :: INFO :: root :: config_parser.py :: 72 :: Syncing drive every 300 seconds.

Traceback (most recent call last):

  File "/app/./src/main.py", line 6, in <module>

    sync.sync()

  File "/app/src/sync.py", line 70, in sync

    sync_photos.sync_photos(config=config, photos=api.photos)

  File "/app/src/sync_photos.py", line 84, in sync_photos

    album=photos.albums[album],

KeyError: 'album 1'

@mandarons
Copy link
Owner

@iPixelOldC Ah.. Looks like you're getting error while authenticating using icloud command line. Please add --region=china to command line authentication step, like below and try again.

icloud --username=*** --session-directory=/app/session_data --region=china

@iPixelOldC
Copy link

iPixelOldC commented Jul 17, 2022

@mandarons Wow, so there's a new parameter? I didn't know that at all. But I seem to be logging in too much now and having some weird problems, obviously the password is correct but he says I'm wrong. Copy and paste too. Changed to another account also. Then I go back to the web login and the same password is logged in. It's so weird. So I created a new container and repeated the previous operation of changing the domain name, same password but it worked.

/app # cat config.yaml 
app:
  logger:
    # level - debug, info (default), warning or error
    level: "info"
    # log filename icloud.log (default)
    filename: "icloud.log"
  credentials:
    # iCloud drive username
    username: "***"
    # Retry login interval - default is 10 minutes
    retry_login_interval: 600
  # Drive destination
  root: "icloud"
  smtp:
    # If you want to recieve email notifications about expired/missing 2FA credentials then uncomment
    # email: "sender@test.com"
    # default to is same as email above
    # to: "receiver@test.com"
    # password:
    # host: "smtp.test.com"
    # port: 587
    # If your email provider doesn't handle TLS
    # no_tls: true
  region: china # valid values are - global (default - uses .com) or china (uses .com.cn)
drive:
  destination: "drive"
  remove_obsolete: false
  sync_interval: 300
  filters:
    # File filters to be included in syncing iCloud drive content
    folders:
      - "folder1"
      - "folder2"
      - "folder3"
    file_extensions:
      # File extensions to be included
      - "pdf"
      - "png"
      - "jpg"
      - "jpeg"
photos:
  destination: "photos"
  remove_obsolete: false
  sync_inteval: 500
  filters:
    albums:
      - "album 1"
      - "album2"
    file_sizes: # valid values are original, medium and/or thumb
      - "original"
      # - "medium"
      # - "thumb"
/app # ls
CODE_OF_CONDUCT.md  README.md           icloud              run-ci.sh           venv
Dockerfile-debug    config.yaml         icloud.log          session_data
LICENSE             generate_badges.py  requirements.txt    src
/app # icloud --username=*** --session-directory=/app/session_data --region=china
Enter iCloud password for ***: 
Bad username or password for ***
Enter iCloud password for ***: 
Bad username or password for ***
Enter iCloud password for ***: 
Traceback (most recent call last):
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 336, in authenticate
    self.session.post(
  File "/app/venv/lib/python3.9/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 131, in request
    self._raise_error(response.status_code, response.reason)
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 187, in _raise_error
    raise api_error
icloudpy.exceptions.ICloudPyAPIResponseException: Not Found (404)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 218, in main
    ICloudPyService(
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 277, in __init__
    self.authenticate()
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 344, in authenticate
    raise ICloudPyFailedLoginException(msg, error) from error
icloudpy.exceptions.ICloudPyFailedLoginException: ('Invalid email/password combination.', ICloudPyAPIResponseException('Not Found (404)'))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/venv/bin//icloud", line 8, in <module>
    sys.exit(main())
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 303, in main
    raise RuntimeError(message) from error
RuntimeError: Bad username or password for ***
/app # ls
CODE_OF_CONDUCT.md  README.md           icloud              run-ci.sh           venv
Dockerfile-debug    config.yaml         icloud.log          session_data
LICENSE             generate_badges.py  requirements.txt    src
/app # cd venv/lib/python3.9/site-packages/icloudpy
/app/venv/lib/python3.9/site-packages/icloudpy # vi base.py #(Modified the same place)
/app/venv/lib/python3.9/site-packages/icloudpy # cd /app
/app # icloud --username=*** --session-directory=/app/session_data
Enter iCloud password for ***: 
Save password in keyring? [y/N]: y

Two-step authentication required. 
Please enter validation code
(string) --> 000000

/app # 

UPDATE: I changed the sync script here to return the global domain name, and I also have the same problem with the password error.

/app # vi src/sync.py # Modified to return the global domain name
/app # icloud --username=***: --session-directory=/app/session_data --region=china
Enter iCloud password for ***: 
Bad username or password for ***:
Enter iCloud password for ***: 
Bad username or password for ***
Enter iCloud password for ***: 
Traceback (most recent call last):
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 336, in authenticate
    self.session.post(
  File "/app/venv/lib/python3.9/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 131, in request
    self._raise_error(response.status_code, response.reason)
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 187, in _raise_error
    raise api_error
icloudpy.exceptions.ICloudPyAPIResponseException: Not Found (404)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 218, in main
    ICloudPyService(
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 277, in __init__
    self.authenticate()
  File "/app/venv/lib/python3.9/site-packages/icloudpy/base.py", line 344, in authenticate
    raise ICloudPyFailedLoginException(msg, error) from error
icloudpy.exceptions.ICloudPyFailedLoginException: ('Invalid email/password combination.', ICloudPyAPIResponseException('Not Found (404)'))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/venv/bin//icloud", line 8, in <module>
    sys.exit(main())
  File "/app/venv/lib/python3.9/site-packages/icloudpy/cmdline.py", line 303, in main
    raise RuntimeError(message) from error
RuntimeError: Bad username or password for ***

/app # cat src/sync.py

def get_api_instance(
    username,
    password,
    cookie_directory=DEFAULT_COOKIE_DIRECTORY,
    server_region="global",
):
    return (
        ICloudPyService(
            apple_id=username,
            password=password,
            cookie_directory=cookie_directory,
            auth_endpoint="https://www.icloud.com",
            setup_endpoint="https://setup.icloud.com/setup/ws/1",
        )
        if server_region == "china"
        else ICloudPyService(
            apple_id=username,
            password=password,
            cookie_directory=cookie_directory,
        )
    )

Then I'm here in the wee hours of the morning, and I have to go to sleep. I'll come back tomorrow to test, bye.

@mandarons mandarons added this to the 1.9.1 milestone Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants