apple-music-token-generator
apple-music-token-generator copied to clipboard
ValueError: Could not deserialize key data.
run python music_token.py
result
Traceback (most recent call last):
File "music_token.py", line 36, in
Im getting the same thing. I used this script in the past and it worked, but not now.
I tested it with alg: HS256, it works.
The problem for me is when I use ES256 which is whats required for Apple Musickit api authentication.
I was facing the same issue and fixed it by reading the .p8 file instead of pasting the key into the script.
secret = open('YourAuthFileNameHere.p8', 'rb').read()
The rest remains the same.
You need change secret, need 3 or 4 lines.
like this: https://github.com/pyca/cryptography/issues/4417#issuecomment-416942613
-----BEGIN PRIVATE KEY-----
MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgsegINAr5xcE48BiD
yfXjsfQmEk1ReGtD7bSuKsKx04CgCgYIKoZIzj0DAQehRANCAASauMCp36D8FOF1
5OGI1+fe5oeRoCbY5yGQ2Jk0Gi9P92ksyvC8LK7JDqtzKfEf18UsScYc+NWffEtt
v413G73q
-----END PRIVATE KEY-----