Page 1 of 1

403 errors

Posted: Sat Oct 28, 2023 11:27 am
by tim97
Hi,

For the past couple of days I have been getting 403 responses when using my Python script to perform GET requests. I made a new consumer for a new API key and performed login operations again to gain a new access token, but no success. I also tried the same operation via the stoplight docs, then it does work. I then copied the example code from the spotlight docs and executed that, but still only get 403 errors.

Re: 403 errors

Posted: Sat Oct 28, 2023 1:46 pm
by oss
Hi

can you show your response including headers ? Did you set up Http User Agent ?

Re: 403 errors

Posted: Sat Oct 28, 2023 4:48 pm
by tim97
Hi,

My GET headers are as follows:

Code: Select all

headers = { 'User-Agent': "MyApp", 'Api-Key': f"apiKey" }
With this being the url

Code: Select all

https://api.opensubtitles.com/api/v1/subtitles?imdb_id=tt4635276&languages=en&season_number=1&episode_number=8
And the response:

Code: Select all

<Response [403]>
And the response headers:

Code: Select all

{'Date': 'Sat, 28 Oct 2023 14:44:58 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'X-Varnish': '112863781', 'Retry-After': '5', 'CF-Cache-Status': 'BYPASS', 'Report-To': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=sMTwlnKIHzW2S3Hluxkg047wrO05Yf0%2Br3WETTeY6ifvek2it%2B%2BuUs%2FX1oZyerRcYi%2BfumwfEDTT0JxWxQ6cDk0EaB5PPAx8IDJNc97Vh3SeAPfAleg6RbYGsHYAl5gsv1tLTJFZcpjamzGlFrxH5j88jzw%3D"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}', 'Vary': 'Accept-Encoding', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains; preload', 'X-Content-Type-Options': 'nosniff', 'Server': 'cloudflare', 'CF-RAY': '81d3f5ba7bee6664-AMS', 'Content-Encoding': 'gzip', 'alt-svc': 'h3=":443"; ma=86400'}
Because the GET request via the stoplight docs did work I thought it might be IP address related. But via a VPN I get the same result.

Re: 403 errors

Posted: Sun Oct 29, 2023 5:29 pm
by oss
Hi

Try to put instead "myapp" which is used as example your real name of application, like "My cool Downloader v0.1"

Re: 403 errors

Posted: Sun Oct 29, 2023 6:10 pm
by tim97
Wow, now it does work, thanks!. Why would this all of a sudden make a difference? My headers have been the same since I started developing a couple of weeks ago.

Re: 403 errors

Posted: Mon Oct 30, 2023 12:47 pm
by oss
Hi

it is because we changed it. We want developers use REAL APPLICATION NAME in headers, not example in our docs.