How to Create a Jwt for Use with Apple Music

How to create a JWT for use with Apple Music

I used this script and it works perfectly
https://github.com/pelauimagineering/apple-music-token-generator

Creating A Developer Token For Apple Music API

I ran into the same problem, make sure your AuthKey.p8 file has the key on one line.
Yours looks like this:

-----BEGIN PRIVATE KEY-----
asdfg1rty5GSM49AgEGCCqGSM49AwEHBHkwdwIBAQQguWRXMHYkuFImkMGByqEPT
jaXQyO0WK1BjYpuDxIgNQ5nHRRFCuUOi8mgCgYIKoZIzj0DAQehcp0+Z+jwRANCAA
RCBFg8fL08QS36Fb8HmY+eFrDWMO00w5unCo5n8VyLhvttIZeByXlVsJrK/L3f/
F2wYmZme
-----END PRIVATE KEY-----

When it should look like this:

-----BEGIN PRIVATE KEY-----
asdfg1rty5GSM49AgEGCCqGSM49AwEHBHkwdwI...
-----END PRIVATE KEY-----

Generating a JWT for Apple's DeviceCheck API

According to: https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6

val builder = Jwts
.builder()
.setHeaderParam("kid", "<key-id-from-file>")
.signWith(SignatureAlgorithm.ES256, privateKey)
.claim("iss", "<team-id>")
.claim("iat", System.currentTimeMillis()) // <--- Should be seconds, not milliseconds


Related Topics



Leave a reply



Submit