streamlink: plugins.kick: 403 Client Error: Forbidden for url

Checklist

Streamlink version

streamlink 6.7.4+12.gbe04a5e

Description

Great thanks to @bastimeyer , Streamlink has finally added the support for kick.com and I couldn’t wait to have a test using the nightly build generated earlier today.

But unfortunately, it seems to have some bug while fetching the livestream and VOD. Both of them prompt an error like error: Unable to open URL: ... (403 Client Error: Forbidden for url: ... )

All livestreams and VODs have the same error, and I also tried to fetch with proxy in Japan/HK and it still prompts the same error, so it might not be a geo-blocking issue.

Debug log

[For livestreams]
streamlink --player "C:\Program Files (x86)\Pure Codec\x64\PotPlayerMini64.exe" --player-no-close --loglevel debug "https://kick.com/ryda" best
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.12.3
[cli][debug] OpenSSL:    OpenSSL 3.0.13 30 Jan 2024
[cli][debug] Streamlink: 6.7.4+12.gbe04a5e
[cli][debug] Dependencies:
[cli][debug]  certifi: 2023.11.17
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.3
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.18.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.31.0
[cli][debug]  trio: 0.22.2
[cli][debug]  trio-websocket: 0.10.3
[cli][debug]  typing-extensions: 4.10.0
[cli][debug]  urllib3: 2.0.3
[cli][debug]  websocket-client: 1.6.1
[cli][debug] Arguments:
[cli][debug]  url=https://kick.com/ryda
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=C:\Program Files (x86)\Pure Codec\x64\PotPlayerMini64.exe
[cli][debug]  --player-no-close=True
[cli][info] Found matching plugin kick for URL https://kick.com/ryda
error: Unable to open URL: https://kick.com/api/v2/channels/ryda/livestream (403 Client Error: Forbidden for url: https://kick.com/api/v2/channels/ryda/livestream)

[For VODs]
streamlink --player "C:\Program Files (x86)\Pure Codec\x64\PotPlayerMini64.exe" --player-no-close --loglevel debug "https://kick.com/video/489e98c0-8c56-4e4f-8ec1-364ff26095bd" best
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.12.3
[cli][debug] OpenSSL:    OpenSSL 3.0.13 30 Jan 2024
[cli][debug] Streamlink: 6.7.4+12.gbe04a5e
[cli][debug] Dependencies:
[cli][debug]  certifi: 2023.11.17
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.3
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.18.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.31.0
[cli][debug]  trio: 0.22.2
[cli][debug]  trio-websocket: 0.10.3
[cli][debug]  typing-extensions: 4.10.0
[cli][debug]  urllib3: 2.0.3
[cli][debug]  websocket-client: 1.6.1
[cli][debug] Arguments:
[cli][debug]  url=https://kick.com/video/489e98c0-8c56-4e4f-8ec1-364ff26095bd
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=C:\Program Files (x86)\Pure Codec\x64\PotPlayerMini64.exe
[cli][debug]  --player-no-close=True
[cli][info] Found matching plugin kick for URL https://kick.com/video/489e98c0-8c56-4e4f-8ec1-364ff26095bd
error: Unable to open URL: https://kick.com/api/v1/video/489e98c0-8c56-4e4f-8ec1-364ff26095bd (403 Client Error: Forbidden for url: https://kick.com/api/v1/video/489e98c0-8c56-4e4f-8ec1-364ff26095bd)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

Kick is filtering out specific HTTP clients depending on the TLS handshakes.

The issue is caused by using OpenSSL 3.2 and below.

Streamlink’s Windows builds and the AppImages both bundle OpenSSL 3.0. The Windows builds are based on CPython’s default build config (but built at streamlink/python-windows-embed), which bundles pre-built OpenSSL binaries from python/cpython-bin-deps. Similar thing for the AppImages, which bundle the pre-built Python env including OpenSSL from the pypa/manylinux repo / docker images. The manylinux_2_28-based AppImages which will soon replace the current manylinux2014 ones will even be based on OpenSSL 1.1.1k, because the manylinux maintainers simply rely on AlmaLinux patches.

So yeah, I think it’s time to remove the plugin again, because we can’t make it work on all systems, especially those where we provide custom Python builds for. I don’t want to go down the rabbit hole and also maintain OpenSSL builds in those envs.


✔️ On my Arch Linux host system using OpenSSL 3.3.0:

$ python -c 'import ssl,requests;print(f"{ssl.OPENSSL_VERSION=}");print(requests.get("https://kick.com/", headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0"}))'
ssl.OPENSSL_VERSION='OpenSSL 3.3.0 9 Apr 2024'
<Response [200]>

✔️ On my macOS VM using OpenSSL 3.3.0:

$ python -c 'import ssl,requests;print(f"{ssl.OPENSSL_VERSION=}");print(requests.get("https://kick.com/", headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0"}))'
ssl.OPENSSL_VERSION='OpenSSL 3.3.0 9 Apr 2024'
<Response [200]>

❌ From Streamlink’s Windows builds using OpenSSL 3.0.13:

$ ./Python/python -c 'import sys;sys.path.append("./pkgs");import ssl,requests;print(f"{ssl.OPENSSL_VERSION=}");print(re
quests.get("https://kick.com/", headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/2010010
1 Firefox/126.0"}))'
ssl.OPENSSL_VERSION='OpenSSL 3.0.13 30 Jan 2024'
<Response [403]>

❌ From Streamlink’s AppImage buildenv docker images using OpenSSL 3.0.13:

$ docker run --rm -it ghcr.io/streamlink/appimage-buildenv-x86_64@sha256:537b8ef991c77cc633d932654aff3372cf7b4c233bb775b5ba8aa191dface5b1 bash -c '/opt/python/cp312-cp312/bin/python -m venv /venv;source /venv/bin/activate;pip install -q requests;python -c "import ssl,requests;print(f\"{ssl.OPENSSL_VERSION=}\");print(requests.get(\"https://kick.com/\", headers={\"User-Agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0\"}))"'
ssl.OPENSSL_VERSION='OpenSSL 3.0.13 30 Jan 2024'
<Response [403]>

❌ From the manylinux_2_28_x86_64 docker images using patched OpenSSL 1.1.1k builds:

$ docker run --rm -it quay.io/pypa/manylinux_2_28_x86_64 bash -c '/opt/python/cp312-cp312/bin/python -m venv /venv;source /venv/bin/activate;pip install -q requests;python -c "import ssl,requests;print(f\"{ssl.OPENSSL_VERSION=}\");print(requests.get(\"https://kick.com/\", headers={\"User-Agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0\"}))"'
ssl.OPENSSL_VERSION='OpenSSL 1.1.1k  FIPS 25 Mar 2021'
<Response [403]>

❌ Debian sid docker image using OpenSSL 3.2.2.

$ docker run --rm -it debian:sid bash -c '(apt-get update;apt-get install -y python-is-python3 python3-venv git)>/dev/null 2>&1;python -m venv /venv;source /venv/bin/activate;pip install -q requests;python -c "import ssl,requests;print(f\\"{ssl.OPENSSL_VERSION=}\\");print(requests.get(\\"https://kick.com/\\", headers={\\"User-Agent\\":\\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0\\"}))"'
ssl.OPENSSL_VERSION='OpenSSL 3.2.2 4 Jun 2024'
<Response [403]>

❌ OpenSUSE Tumbleweed docker image using OpenSSL 3.1.4

$ docker run --rm -it opensuse/tumbleweed bash -c 'zypper -n install python3 git >/dev/null 2>&1;python3 -m venv /venv;source /venv/bin/activate;pip install -q requests;python -c "import ssl,requests;print(f\\"{ssl.OPENSSL_VERSION=}\\");print(requests.get(\\"https://kick.com/\\", headers={\\"User-Agent\\":\\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0\\"}))"'
ssl.OPENSSL_VERSION='OpenSSL 3.1.4 24 Oct 2023'
<Response [403]>

I was able to get this to work, though I don’t actually understand if this is the correct way to do this:

Just a followup, from a cursory search, it seems this is a pretty standard setup.

For a patch, adding this to SSLContextAdapter seems to fix this:

diff --git a/src/streamlink/session/http.py b/src/streamlink/session/http.py
index 1c972a7d..90608f56 100644
--- a/src/streamlink/session/http.py
+++ b/src/streamlink/session/http.py
@@ -212,6 +212,10 @@ class SSLContextAdapter(HTTPAdapter):
     def init_poolmanager(self, *args, **kwargs):
         kwargs["ssl_context"] = self.get_ssl_context()
         return super().init_poolmanager(*args, **kwargs)
+
+    def proxy_manager_for(self, *args, **kwargs):
+        kwargs["ssl_context"] = self.get_ssl_context()
+        return super().proxy_manager_for(*args, **kwargs)


 class TLSNoDHAdapter(SSLContextAdapter):

I tested and it successfully solved the problem. Thank you so much!

(I’m completely a newbie in Python, I added those codes first time by giving tabs at the top of each line to make indentation. Now I know it should be four spaces.)