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

Xtream API - Error 403 (Forbidden) if requests sent without user-agent [with solution] #274

Open
diegobenincasa opened this issue Apr 27, 2023 · 2 comments

Comments

@diegobenincasa
Copy link

I found a bug where Hypnotix is unable to authenticate to Xtream API if user-agent is not sent in header request. But as I tried the URL in browser and it worked out of the box, I gave a try looking for the issue - and found it: Xtream API refuses to authenticate if User-Agent is not sent as a request header.

But I found a really easy workaround (not with time now to create a pull request).

  1. In file xtream.py, method authenticate(self), just at the start of try block, add:
    headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'}
    And at the next line (where requests takes place), add a new parameter headers=headers.

  2. Also in the same xtream.py file, in method _get_request(self, URL: str, timeout: Tuple = (2,15)), add the same headers definition (as described upwards) before the try block and, just after it, in the requests call, add the new parameter headers=headers.

That should do the trick!

@superolmo
Copy link
Contributor

Could you test the Pull Request I have with your xtream account and write a comment if it works for you?
Instructions to test PR in case you are not aware: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally?tool=webui

@diegobenincasa
Copy link
Author

@superolmo Sorry for my delayed response.
No, it does not work either. I'll test with user-agent set-up inside code again and see if it works. I'll try to post a new status soon.

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

No branches or pull requests

2 participants