C0D3D3V/Moodle-DL

The Moodle System rejected the Request [invalidprivatetoken]

Closed this issue · 1 comments

Description of the bug

Hey! I just updated to the and when I trying to run moodle-dl I get:

Cookie lockout: The Moodle System rejected the Request. Details: moodle_exception (Error code: invalidprivatetoken, Message: private token not valid. The token must be not empty or passed through the GET parameter.)
Full log:

2024-04-16 20:08:28  DEBUG  {connectionpool}  Starting new HTTPS connection (1): moodle.uni.lol:443
2024-04-16 20:08:28  DEBUG  {connectionpool}  https://moodle.uni.lol:443 "POST /webservice/rest/server.php?moodlewsrestformat=json&wsfunction=tool_mobile_get_autologin_key HTTP/1.1" 200 None
2024-04-16 20:08:28  DEBUG  {request_helper}  Details about the failed request:
URL: https://moodle.uni.lol/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=tool_mobile_get_autologin_key
Body: {'moodlewssettingfilter': 'true', 'moodlewssettingfileurl': 'true', 'privatetoken': 'censored', 'wsfunction': 'tool_mobile_get_autologin_key', 'wstoken': 'censored'}
2024-04-16 20:08:28  DEBUG  {cookie_handler}  Cookie lockout: The Moodle System rejected the Request. Details: moodle_exception (Error code: invalidprivatetoken, Message: Invalid private token. The token must not be empty or passed through the GET parameter.)
2024-04-16 20:08:28  DEBUG  {cookie_handler}  Failed to download autologin key!
2024-04-16 20:08:28  DEBUG  {connectionpool}  Starting new HTTPS connection (1): moodle.uni.lol:443
2024-04-16 20:08:30  DEBUG  {connectionpool}  https://moodle.uni.lol:443 "POST /webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_enrol_get_users_courses HTTP/1.1" 200 None
2024-04-16 20:08:30  INFO  {utils}  [ 5/11] Loaded course core 1 "a"
2024-04-16 20:08:30  INFO  {utils}  [ 8/11] Loaded course core 2 "b"
2024-04-16 20:08:30  INFO  {utils}  [ 3/11] Loaded course core 3 "c"
2024-04-16 20:08:30  INFO  {utils}  [ 6/11] Loaded course core 4 "d"
2024-04-16 20:08:30  INFO  {utils}  [ 7/11] Loaded course core 5 "e"
2024-04-16 20:08:30  INFO  {utils}  [ 2/11] Loaded course core 6 "f"
2024-04-16 20:08:30  INFO  {utils}  [ 4/11] Loaded course core 7 "g"
2024-04-16 20:08:30  INFO  {utils}  [10/11] Loaded course core 8 "h"
2024-04-16 20:08:30  INFO  {utils}  [ 1/11] Loaded course core 9 "i"
2024-04-16 20:08:31  INFO  {utils}  [ 9/11] Loaded course core 10 "j"
2024-04-16 20:08:31  INFO  {utils}  [11/11] Loaded course core 11 "k"
The following error occurred during execution:
'NoneType' object is not subscriptable
2024-04-16 20:08:31  DEBUG  {mail_service}  Mail-Notifications not configured, skipping.
2024-04-16 20:08:31  DEBUG  {telegram_service}  Telegram-Notifications not configured, skipping.
2024-04-16 20:08:31  DEBUG  {xmpp_service}  XMPP-Notifications not configured, skipping.
2024-04-16 20:08:31  ERROR  {main}  Traceback (most recent call last):
  File "/home/user/.local/lib/python3.12/site-packages/moodle_dl/main.py", line 547, in main
    choose_task(config, opts)
  File "/home/user/.local/lib/python3.12/site-packages/moodle_dl/main.py", line 70, in choose_task
    run_main(config, opts)
  File "/home/user/.local/lib/python3.12/site-packages/moodle_dl/main.py", line 138, in run_main
    raise base_err
  File "/home/user/.local/lib/python3.12/site-packages/moodle_dl/main.py", line 97, in run_main
    changed_courses = asyncio.run(moodle.fetch_state(database))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.12/site-packages/moodle_dl/moodle/moodle_service.py", line 116, in fetch_state
    mods = get_all_mods(request_helper, version, user_id, database.get_last_timestamp_per_mod_module(), self.config)
                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.12/site-packages/moodle_dl/database.py", line 550, in get_last_timestamp_per_mod_module
    mod_calendar_dict[course_row['module_id']] = course_row['content_timemodified']
                                                 ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

I censored private information if anything looks weird.

I downgraded to moodle-dl 2.3.2.5 and It seems to work fine. Probably something that changed in the new versions.

Thank you ! :)

Steps to reproduce the issue

Run moodle-dl normally.

Expected behavior

Possible Fix

Technical details

  • OS: Fedora 39
  • Moodle-DL Version 2.3.5

Thank you for the report. 🤗