edx-dl icon indicating copy to clipboard operation
edx-dl copied to clipboard

HTTP Error 400: Bad Request

Open iraj-jelo opened this issue 5 years ago • 7 comments

🚨Please review the Troubleshooting section before reporting any issue. Don't forget also to check the current issues to avoid duplicates.

Subject of the issue

on version 0.1.11

running edx-dl -u [email protected] https://... gives an error like:

Logging into Open edX site: https://courses.edx.org/login_ajax
Traceback (most recent call last):
  File "/usr/local/bin/edx-dl", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/edx_dl/edx_dl.py", line 1003, in main
    resp = edx_login(LOGIN_API, headers, args.username, args.password)
  File "/usr/local/lib/python3.6/dist-packages/edx_dl/edx_dl.py", line 224, in edx_login
    response = urlopen(request)
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

what's wrong with that?

Your environment

  • Operating System (name/version): Ubuntu 18:04
  • Python version: 3.6
  • youtube-dl version: 2019.11.05
  • edx-dl version: 0.1.11

Expected behaviour

I should be able download the course

Actual behaviour

I got a HTTP error

iraj-jelo avatar Dec 22 '19 03:12 iraj-jelo

this line https://github.com/coursera-dl/edx-dl/blob/32a21912a2b8e7e44b287741cfceb56beae9d721/edx_dl/edx_dl.py#L100

and this line https://github.com/coursera-dl/edx-dl/blob/32a21912a2b8e7e44b287741cfceb56beae9d721/edx_dl/edx_dl.py#L122

should be replaced with:

LOGIN_API = BASE_URL + '/user_api/v1/account/login_session'

iraj-jelo avatar Dec 22 '19 05:12 iraj-jelo

I still get below error though

Wrong Email or Password.

iraj-jelo avatar Dec 22 '19 07:12 iraj-jelo

@iraj-jelo this works for me, check it out.

ievgent avatar Dec 22 '19 12:12 ievgent

I changed it to your version, but I'm still getting the same error urllib.error.HTTPError: HTTP Error 400: Bad Request

iraj-jelo avatar Dec 22 '19 12:12 iraj-jelo

I ran into the same issue and found that it can be caused by:

  • Wrong username/password
  • edX temporarily locking your account due to failing too many log-in attempts

If your account gets locked, try waiting a few hours and resetting your password before trying again.

joeyvanlierop avatar Jan 05 '20 00:01 joeyvanlierop

@ievgent and @joeyvanlierop 's tips combined fixed my issue. Please integrate this commit into the new release :)

TjWallas avatar May 05 '20 19:05 TjWallas

I ran into the same issue and found that it can be caused by:

  • Wrong username/password
  • edX temporarily locking your account due to failing too many log-in attempts

If your account gets locked, try waiting a few hours and resetting your password before trying again.

I reset my password but the issue persists

anniechakraborty avatar Jun 15 '20 15:06 anniechakraborty