我正在尝试生成 Apple Music JWT 令牌。
我有有效的 keyId、teamId 和 .p8 文件 + 我已经安装了最新版本的 pyjwt & cryptography。
当我尝试执行时,python music_token.py
我收到以下错误。
(在这里下载了 music_token.py 脚本)
Traceback (most recent call last):
File "music_token.py", line 33, in <module>
token = jwt.encode(payload, secret, algorithm=alg, headers=headers)
File "/Library/Python/2.7/site-packages/jwt/api_jwt.py", line 56, in encode
json_payload, key, algorithm, headers, json_encoder
File "/Library/Python/2.7/site-packages/jwt/api_jws.py", line 102, in encode
key = alg_obj.prepare_key(key)
File "/Library/Python/2.7/site-packages/jwt/algorithms.py", line 351, in prepare_key
key = load_pem_private_key(key, password=None, backend=default_backend())
File "/Library/Python/2.7/site-packages/cryptography/hazmat/primitives/serialization.py", line 20, in load_pem_private_key
return backend.load_pem_private_key(data, password)
File "/Library/Python/2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1015, in load_pem_private_key
password,
File "/Library/Python/2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1234, in _load_key
self._handle_key_loading_error()
File "/Library/Python/2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1292, in _handle_key_loading_error
raise ValueError("Could not deserialize key data.")
ValueError: Could not deserialize key data.
如果我在这里做错了什么,有人可以指出我正确的方向吗?
我尝试在谷歌上搜索,它提示安装的版本可能存在问题,jwt
但我安装了最新版本。