tuttle-dev / tuttle

🪰 Tuttle - time and money management for freelancers
GNU General Public License v3.0
62 stars 12 forks source link

Bug: Login with icloud #139

Closed vlad-ed-git closed 1 year ago

vlad-ed-git commented 1 year ago

Despite the apple_id being set, when trying to login into iCloud account the following exception is raised: Invalid authentication token.', ICloudPyAPIResponseException('Missing apple_id field'

The gist of the logged result: Exception raised @login_iCloud during authentication of my_actual_account@icloud.com ICloudPyFailedLoginException icloudpy.exceptions.ICloudPyFailedLoginException: ('Invalid authentication token.', ICloudPyAPIResponseException('Missing apple_id field'))

Complete stack trace below:

`ERROR:icloudpy.base:Missing apple_id field
2023-01-15 01:41:27.073 | ERROR    | tuttle.cloud:login_iCloud:80 - Exception raised @login_iCloud during authentication of my_actual_account@icloud.com ICloudPyFailedLoginException
2023-01-15 01:41:27.073 | ERROR    | tuttle.cloud:login_iCloud:83 - ('Invalid authentication token.', ICloudPyAPIResponseException('Missing apple_id field'))
Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/icloudpy/base.py", line 362, in _authenticate_with_token
    req = self.session.post(
          │    │       └ <function Session.post at 0x104002050>
          │    └ <icloudpy.base.ICloudPySession object at 0x1241e0790>
          └ <iCloud API: my_actual_account@icloud.com>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           │    │               │         │          │       └ {}
           │    │               │         │          └ None
           │    │               │         └ '{"accountCountryCode": null, "dsWebAuthToken": null, "extended_login": true, "trustToken": ""}'
           │    │               └ 'https://setup.icloud.com/setup/ws/1/accountLogin'
           │    └ <function ICloudPySession.request at 0x1217a0700>
           └ <icloudpy.base.ICloudPySession object at 0x1241e0790>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/icloudpy/base.py", line 158, in request
    self._raise_error(code, reason)
    │    │            │     └ 'Missing apple_id field'
    │    │            └ None
    │    └ <function ICloudPySession._raise_error at 0x1217a0790>
    └ <icloudpy.base.ICloudPySession object at 0x1241e0790>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/icloudpy/base.py", line 187, in _raise_error
    raise api_error
          └ ICloudPyAPIResponseException('Missing apple_id field')

icloudpy.exceptions.ICloudPyAPIResponseException: Missing apple_id field

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

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 973, in _bootstrap
    self._bootstrap_inner()
    │    └ <function Thread._bootstrap_inner at 0x1012ff010>
    └ <Thread(Thread-80 (<lambda>), started daemon 6206664704)>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
    │    └ <function Thread.run at 0x1012fed40>
    └ <Thread(Thread-80 (<lambda>), started daemon 6206664704)>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
    │    │        │    │        │    └ {}
    │    │        │    │        └ <Thread(Thread-80 (<lambda>), started daemon 6206664704)>
    │    │        │    └ (<flet.control_event.ControlEvent object at 0x1244b7700>,)
    │    │        └ <Thread(Thread-80 (<lambda>), started daemon 6206664704)>
    │    └ <function NewTimeTrackPopUp.__init__.<locals>.<lambda> at 0x1244b95a0>
    └ <Thread(Thread-80 (<lambda>), started daemon 6206664704)>

  File "/Users/vlad/Desktop/vlad/tuttle/app/timetracking/view.py", line 103, in <lambda>
    on_click=lambda e: self.on_submit_btn_clicked(
                    │  │    └ <function NewTimeTrackPopUp.on_submit_btn_clicked at 0x12417eb90>
                    │  └ <timetracking.view.NewTimeTrackPopUp object at 0x124407ee0>
                    └ <flet.control_event.ControlEvent object at 0x1244b7700>

  File "/Users/vlad/Desktop/vlad/tuttle/app/timetracking/view.py", line 159, in on_submit_btn_clicked
    self.on_submit_callback(
    │    └ <bound method TimeTrackingView.on_add_new_timetrack_record_callback of <timetracking.view.TimeTrackingView object at 0x12449a...
    └ <timetracking.view.NewTimeTrackPopUp object at 0x124407ee0>

  File "/Users/vlad/Desktop/vlad/tuttle/app/timetracking/view.py", line 219, in on_add_new_timetrack_record_callback
    self.on_load_from_calendar(info=cloud_calendar_info)
    │    │                          └ CloudCalendarInfo(account='my_actual_account@icloud.com', calendar_name='bljoo', provider='iCloud', password='oojpkjj')
    │    └ <function TimeTrackingView.on_load_from_calendar at 0x12417f010>
    └ <timetracking.view.TimeTrackingView object at 0x12449a830>

  File "/Users/vlad/Desktop/vlad/tuttle/app/timetracking/view.py", line 293, in on_load_from_calendar
    result = self.intent.configure_account_and_load_calendar_intent(
             │    │      └ <function TimeTrackingIntent.configure_account_and_load_calendar_intent at 0x12417e8c0>
             │    └ <timetracking.intent.TimeTrackingIntent object at 0x12449a860>
             └ <timetracking.view.TimeTrackingView object at 0x12449a830>

  File "/Users/vlad/Desktop/vlad/tuttle/app/timetracking/intent.py", line 112, in configure_account_and_load_calendar_intent
    res = self._data_source.login_to_icloud(calendar_info=calendar_info)
          │    │            │                             └ CloudCalendarInfo(account='my_actual_account@icloud.com', calendar_name='bljoo', provider='iCloud', password='oojpkjj')
          │    │            └ <function TimeTrackingDataSource.login_to_icloud at 0x12417e4d0>
          │    └ <timetracking.data_source.TimeTrackingDataSource object at 0x12449a890>
          └ <timetracking.intent.TimeTrackingIntent object at 0x12449a860>

  File "/Users/vlad/Desktop/vlad/tuttle/app/timetracking/data_source.py", line 83, in login_to_icloud
    cloud_login_result: CloudLoginResult = login_iCloud(
                                           └ <function login_iCloud at 0x121a70790>

> File "/Users/vlad/Desktop/vlad/tuttle/tuttle/cloud.py", line 72, in login_iCloud
    iCloud = icloudpy.ICloudPyService(apple_id=user_name, password=password)
             │        │                        │                   └ 'oojpkjj'
             │        │                        └ 'my_actual_account@icloud.com'
             │        └ <class 'icloudpy.base.ICloudPyService'>
             └ <module 'icloudpy' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/icloudpy/__init__.py'>

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/icloudpy/base.py", line 277, in __init__
    self.authenticate()
    │    └ <function ICloudPyService.authenticate at 0x1217a0940>
    └ <iCloud API: my_actual_account@icloud.com>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/icloudpy/base.py", line 346, in authenticate
    self._authenticate_with_token()
    │    └ <function ICloudPyService._authenticate_with_token at 0x1217a09d0>
    └ <iCloud API: my_actual_account@icloud.com>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/icloudpy/base.py", line 368, in _authenticate_with_token
    raise ICloudPyFailedLoginException(msg, error) from error
          │                            └ 'Invalid authentication token.'
          └ <class 'icloudpy.exceptions.ICloudPyFailedLoginException'>

icloudpy.exceptions.ICloudPyFailedLoginException: ('Invalid authentication token.', ICloudPyAPIResponseException('Missing apple_id field'))
clstaudt commented 1 year ago

ChatGPT debug suggestions:

This error message suggests that there is a problem with the apple_id field when trying to login to the iCloud account. It's possible that the apple_id field is not being set correctly or is not being passed along with the login request. It is also possible that the field is not present in the API request payload. It's also possible that the code is using an older version of the API, and the API no longer supports the apple_id field. It's best to check the Icloudpy API documentation and ensure that the apple_id field is being set correctly and passed along with the login request, also check the version of the API being used is the latest one. If the issue persists, please consider reaching out to the package developer for additional assistance.

vlad-ed-git commented 1 year ago

Closing as seems to be an issue with my icloud account.