mandarons / icloudpy

iCloud web service interface library in Python
Other
188 stars 19 forks source link

icloudpy.exceptions.ICloudPyFailedLoginException: ('Invalid authentication token.', ICloudPyAPIResponseException('Missing apple_id field')) #43

Open Echoooo0827 opened 2 months ago

Echoooo0827 commented 2 months ago

I got the following exception when I ran it

Traceback (most recent call last):
  File "C:\Work\Env\python\Lib\site-packages\icloudpy\base.py", line 364, in _authenticate_with_token
    req = self.session.post(
  File "C:\Work\Env\python\Lib\site-packages\requests\sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "C:\Work\Env\python\Lib\site-packages\icloudpy\base.py", line 158, in request
    self._raise_error(code, reason)
  File "C:\Work\Env\python\Lib\site-packages\icloudpy\base.py", line 187, in _raise_error
    raise api_error
icloudpy.exceptions.ICloudPyAPIResponseException: Missing apple_id field

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

Traceback (most recent call last):
  File "C:\Work\pythonProjects\demo\pythonProject\find-my-phone-demo-02.py", line 4, in <module>
    api = ICloudPyService('*****', '******', home_endpoint="https://www.icloud.com.cn",setup_endpoint="https://setup.icloud.com.cn/setup/ws/1",)
  File "C:\Work\Env\python\Lib\site-packages\icloudpy\base.py", line 279, in __init__
    self.authenticate()
  File "C:\Work\Env\python\Lib\site-packages\icloudpy\base.py", line 348, in authenticate
    self._authenticate_with_token()
  File "C:\Work\Env\python\Lib\site-packages\icloudpy\base.py", line 370, in _authenticate_with_token
    raise ICloudPyFailedLoginException(msg, error) from error
icloudpy.exceptions.ICloudPyFailedLoginException: ('Invalid authentication token.', ICloudPyAPIResponseException('Missing apple_id field'))

How can I test it to make it work?

Here is my run test code

from icloudpy import ICloudPyService
# api = ICloudPyService('jappleseed@apple.com', 'password')
# For China region
api = ICloudPyService('13925629668', 'xrf64668', home_endpoint="https://www.icloud.com.cn",setup_endpoint="https://setup.icloud.com.cn/setup/ws/1",)

if __name__ == '__main__':
    print(api)
mandarons commented 2 months ago

Try providingcookie_directory parameter pointing to some local directory path. Also, double check username and password. Username should be your icloud email address and password should be icloud.com password (and not application password).

14278358 commented 1 month ago

尝试提供cookie_directory指向某个本地目录路径的参数。另外,请仔细检查用户名和密码。用户名应该是您的 icloud 电子邮件地址,密码应该是 icloud.com 密码(而不是应用程序密码)。

Encountered the same problem, and this happened again for accounts without 2FA authentication.