aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-10-28 02:07:15 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-10-28 02:07:41 +0530
commit16b0d7e621c2fb4dc23e88f9b3e1a7b61cf5c60e (patch)
tree5fde715d75d4e56d0c71e39080b4d5215792497d
parent5be76d1ab7fed65a5894b221c7b7f896a18fc820 (diff)
downloadhypervideo-pre-16b0d7e621c2fb4dc23e88f9b3e1a7b61cf5c60e.tar.lz
hypervideo-pre-16b0d7e621c2fb4dc23e88f9b3e1a7b61cf5c60e.tar.xz
hypervideo-pre-16b0d7e621c2fb4dc23e88f9b3e1a7b61cf5c60e.zip
[utils] Add `jwt_decode_hs256`
Code from #1340 Authored by: Ashish0804
-rw-r--r--yt_dlp/utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 48baa6503..080bf260a 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -6512,6 +6512,13 @@ def jwt_encode_hs256(payload_data, key, headers={}):
return token
+# can be extended in future to verify the signature and parse header and return the algorithm used if it's not HS256
+def jwt_decode_hs256(jwt):
+ header_b64, payload_b64, signature_b64 = jwt.split('.')
+ payload_data = json.loads(base64.urlsafe_b64decode(payload_b64))
+ return payload_data
+
+
def supports_terminal_sequences(stream):
if compat_os_name == 'nt':
if get_windows_version() < (10, 0, 10586):