Forums

Error connecting to udemy api

Dear PythonAnywhere,

I have this app on the domain: http://r3ap3rpy.pythonanywhere.com/udemy

It tries to pull information from the API of udemy based on my client ID and client SECRET, it works on my test PC. But when I try to push it on the pythonanywhere it fails.

Maybe it needs some whitelisting if possible? I saw other forum posts which indicated the same type of error.

This is an error I get.

Start of ERROR

2018-12-10 09:47:58,158: requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.udemy.com', port=443): Max retries exceeded with url: /api-2.0/courses/?search=Szab%C3%B3%20D%C3%A1niel%20Ern%C5%91 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))
2018-12-10 09:50:04,915: [2018-12-10 09:50:04,902] ERROR in app: Exception on /udemy [GET]
2018-12-10 09:50:04,915: Traceback (most recent call last):
2018-12-10 09:50:04,915:   File "/home/r3ap3rpy/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 594, in urlopen
2018-12-10 09:50:04,916:     self._prepare_proxy(conn)
2018-12-10 09:50:04,916:   File "/home/r3ap3rpy/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 815, in _prepare_proxy
2018-12-10 09:50:04,916:     conn.connect()
2018-12-10 09:50:04,916:   File "/home/r3ap3rpy/.local/lib/python3.6/site-packages/urllib3/connection.py", line 324, in connect
2018-12-10 09:50:04,916:     self._tunnel()
2018-12-10 09:50:04,916:   File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
2018-12-10 09:50:04,916:     message.strip()))
2018-12-10 09:50:04,916: OSError: Tunnel connection failed: 403 Forbidden

END OF ERRROR

Can you please help?

Cheers, Daniel

[edit by admin: formatting]

Could you send us a link to the Udemy docs where they say that there is an API at www.udemy.com?

Hello,

Thanks for the fast reply.

Here is the link to the official documentation: https://www.udemy.com/developers/affiliate/

Not sure if you can access it without registration.

But the endpoint is this: https://www.udemy.com/api-2.0/

On that we can access with cliendID and clientSecret the following context roots.

GET /api-2.0/courses/{course_id}/reviews/ GET /api-2.0/courses/{pk}/ GET /api-2.0/courses/ GET /api-2.0/courses/{course_id}/public-curriculum-items/

Let me know if you need more information.

Cheers, Daniel

Thanks! That was exactly what we needed. I've whitelisted the site now.

Thank you!

I have just checked and It's working perfectly.

Have a nice day, and thumbs up for the support!!!!!!!

PS: A long time fan!

Excellent! Many thanks for confirming :-)