MusicKit JS - Invalid JWT validation

I have a web-app that is recently experiencing problems with users not being able to connect their Apple Music account. It was working perfectly up until now, it may be something with how my dependencies changed but I doubt that.

In any case, once I invoke requestUserToken(), the tab is opened, and after authentication they get "Problem Connecting - There may be a network issue."

Upon hitting "Try Again" the same error message appears, but this time the URL bar shows something along the lines of "ERROR_FAILED_TO_VERIFY_JWT&pod=10".

What can be the reason for this?

Replies

I've just checked and double-checked and according to jwt.io I have a perfectly valid ES256 token, which resolves to the same shape expected by Apple in the documentation, shape:

{
     "alg": "ES256",
     "kid": "ABC123DEFG"
}
{
     "iss": "DEF123GHIJ",
     "iat": 1437179036,
     "exp": 1493298100
}

I can even decode the token presented in the authentication window:

https://authorize.music.apple.com/woa?a=[[TOKEN_THAT_VALIDATES_PERFECTLY]]&referrer=[[MY_WEBSITE_URL]]/&app=music&p=subscribe

The app itself is able to communicate with Apple Music API just fine, it works perfectly using the same token encoding function that I use and return to MusicKit JS. So it's definitely a problem on Apple's side.

Any chance you solved this? I am having the same issue.

Thank you for reaching out, @zeroedge, and I apologize for the delayed response

In order to investigate this issue, it would be helpful if you could file a ticket on the Feedback Assistant, including a .har export of the network inspector that shows any error responses, console logs, and any other relevant information.