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

400 Client Error: while using --list-courses #773

Open
anmolthedeveloper opened this issue Sep 2, 2020 · 15 comments · May be fixed by #824
Open

400 Client Error: while using --list-courses #773

anmolthedeveloper opened this issue Sep 2, 2020 · 15 comments · May be fixed by #824

Comments

@anmolthedeveloper
Copy link

anmolthedeveloper commented Sep 2, 2020

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

@mararkeri
Copy link

mararkeri commented Sep 20, 2020

Create a file coursera-dl.conf in the same directory of the coursera-dl with the text below:
--username <email_here>
--password <passwd_here>
--subtitle-language en
--cauth

cauth value will be available only if you login to coursera and then check in cookies.
You may check the following video:
https://youtu.be/xpy0H4T9zHU

If you don't know how to use coursera-dl, you can check following video:
https://youtu.be/wP9ZyTRIAS4

@zorone
Copy link

zorone commented Sep 28, 2020

I have this problem too. But when added --list-courses only .

@zorone
Copy link

zorone commented Sep 28, 2020

I have fixed it. And I can use it without a problem. Here is my fixing code:
https://github.com/zorone/coursera-dl

@bhrgunatha
Copy link

bhrgunatha commented Oct 6, 2020

I have the same problem.

@mararkeri - Thank you for those links however, to be clear, login using cauth works when you download a specific course/ciourses, but not when you try to list your current courses using --list-courses

@bhrgunatha
Copy link

I have fixed it. And I can use it without a problem. Here is my fixing code:
https://github.com/zorone/coursera-dl

Please submit a pull request so the maintainers will see your solution and everyone can benefit.

@zorone
Copy link

zorone commented Oct 6, 2020

@bhrgunatha I can't push my new branch into their repo.

remote: Permission to coursera-dl/coursera-dl.git denied to zorone.
fatal: unable to access 'https://github.com/coursera-dl/coursera-dl.git/': The requested URL returned error: 403

@zorone
Copy link

zorone commented Oct 6, 2020

@mararkeri Please Check my code,

https://github.com/zorone/coursera-dl

I have edit some code in coursera/coursera-dl.

@bhrgunatha
Copy link

bhrgunatha commented Oct 6, 2020

@zorone

I can't push my new branch into their repo.

No, you won't have permission to push code to this repository.

Instead you submit a pull request that bundles up the changes that you have made to your repository. Then the devs here can review the changes you've made and decide whether to accept it or not.

@souhaibdjaballah
Copy link

Create a file coursera-dl.conf in the same directory of the coursera-dl with the text below:
--username <email_here>
--password <passwd_here>
--subtitle-language en
--cauth

cauth value will be available only if you login to coursera and then check in cookies.
You may check the following video:
https://youtu.be/xpy0H4T9zHU

If you don't know how to use coursera-dl, you can check following video:
https://youtu.be/wP9ZyTRIAS4

It works, thank you!

@sancho-s
Copy link

sancho-s commented May 6, 2021

Is the current version supposed to fix

coursera.cookies.AuthenticationFailed: Cannot login on coursera.org: 400 Client Error: Bad Request for url: https://api.coursera.org/api/login/v3

when using --list-courses?
I added file coursera-dl.conf as instructed above, and it was enough to solve the problem when downloading material.
But --list-courses still produces the issue above for me.

@clissa
Copy link

clissa commented Jun 28, 2021

Is cauth still supposed to solve the problem? I tried following the instructions here using version 0.11.4 but I get:

coursera-dl: error: unrecognized arguments: --cauth=XKJD-...

If I correctly understood cauth option was added from version 0.11.5, so I retried re-installing from scratch in a new environment but still 0.11.4 seem to be the latest version found. Then I also tried downloading 0.11.5 zip file from github but surprisingly I still see: coursera_dl version 0.11.4 when I launch coursera-dl command. However, this time the coursera python package is on the expected version:

>>> import coursera
>>> coursera.__version__
'0.11.4'

Do you have any suggestion?

@zorone
Copy link

zorone commented Jun 30, 2021

I found that auth function aren't applied to --list-courses . Please check this https://github.com/zorone/coursera-dl. I have fix that long time ago. But beacause it doesn't pass test cases, so I didn't commit it to the project. Give it a try.

@jarrettyeo
Copy link

Create a file coursera-dl.conf in the same directory of the coursera-dl with the text below: --username <email_here> --password <passwd_here> --subtitle-language en --cauth

cauth value will be available only if you login to coursera and then check in cookies.
You may check the following video:
https://youtu.be/xpy0H4T9zHU

Just for the record, you need to provide your CAUTH value after --cauth. This can be taken from the CAUTH cookie after logging into Chrome from your browser

@olawalejuwonm
Copy link

Is the current version supposed to fix

coursera.cookies.AuthenticationFailed: Cannot login on coursera.org: 400 Client Error: Bad Request for url: https://api.coursera.org/api/login/v3

when using --list-courses? I added file coursera-dl.conf as instructed above, and it was enough to solve the problem when downloading material. But --list-courses still produces the issue above for me.

Same here
Have you been able to resolve it?

@holocronweaver
Copy link

Created a pull request on behalf of quick fix by @zorone: #824

@holocronweaver holocronweaver linked a pull request May 26, 2022 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants