400 Client Error: while using --list-courses

Author: anmolthedeveloperCreated Sep 2, 2020Updated Oct 21, 2024

Subject of the issue

Got error while trying to use --list-courses.

Your environment

  • Operating System (name/version): Windows 10
  • Python version: 3.8.5
  • coursera-dl version: 0.11.5

Steps to reproduce

Tell us how to reproduce this issue, please don't forget to include enough information so that you can help us help you:

Just use cookies and --list-courses flag: coursera-dl -ca cookie-from-browser-xxxx --list-courses

replacing cookie-from-browser-xxxx from my original cookie value to protect privacy and security reasons

  • Is the problem happening with the latest version of the script? Yes.

  • Do you have all the recommended versions of the modules? See them in the file requirements.txt. Yes.

  • What is the course that you are trying to access? I was just trying to list them all.

  • What is the precise command line that you are using (don't forget to obfuscate your username and password, but leave all other information untouched). coursera-dl -ca cookie-from-browser-xxxx --list-courses

  • What are the precise messages that you get? Please, use the --debug option before posting the messages as a bug report. Please, copy and paste them. Don't reword/paraphrase the messages. root[main] coursera_dl version 0.11.5 root[main] Listing enrolled courses root[login] Initiating login. root[login] There were no .coursera.org cookies to be cleared. root[prepare_auth_headers] Forging cookie header: csrftoken=fPRydo2dr7zChF1dK3iN; csrf2_token_WDJzh5ph=8hnrtIYn1wYv0DfRrlt9S9FK. urllib3.connectionpool[_new_conn] Starting new HTTPS connection (1): api.coursera.org:443 urllib3.connectionpool[_make_request] https://api.coursera.org:443 "POST /api/login/v3 HTTP/1.1" 400 None Traceback (most recent call last): File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\cookies.py", line 148, in login r.raise_for_status() File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.coursera.org/api/login/v3

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\Scripts\coursera-dl-script.py", line 11, in load_entry_point('coursera-dl==0.11.5', 'console_scripts', 'coursera-dl')() File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\coursera_dl.py", line 232, in main list_courses(args) File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\coursera_dl.py", line 108, in list_courses login(session, args.username, args.password) File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\cookies.py", line 155, in login raise AuthenticationFailed('Cannot login on coursera.org: %s' % e) coursera.cookies.AuthenticationFailed: Cannot login on coursera.org: 400 Client Error: Bad Request for url: https://api.coursera.org/api/login/v3

Expected behaviour

Tell us what should happen. It should have print the list of courses that i have enrolled

Actual behaviour

Tell us what happens instead. If the script fails, please copy the entire output of the command or the stacktrace (don't forget to obfuscate your username and password). If you cannot copy the exception, attach a screenshot.

coursera_dl version 0.11.5 Traceback (most recent call last): File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\cookies.py", line 148, in login r.raise_for_status() in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.coursera.org/api/login/v3

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\Scripts\coursera-dl-script.py", line 11, in load_entry_point('coursera-dl==0.11.5', 'console_scripts', 'coursera-dl')() File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\coursera_dl.py", line 232, in main list_courses(args) File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\coursera_dl.py", line 108, in list_courses login(session, args.username, args.password) File "C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\coursera_dl-0.11.5-py3.8.egg\coursera\cookies.py", line 155, in login raise AuthenticationFailed('Cannot login on coursera.org: %s' % e) coursera.cookies.AuthenticationFailed: Cannot login on coursera.org: 400 Client Error: Bad Request for url: https://api.coursera.org/api/login/v3