MusicKit JS v3 authentication failure

When attempting to authenticate with the musickit-js v3, the page that gets loaded from authorize.music.apple.com results in an error "Cannot parse response"

On the desktop, this does not happen.

The authentication code in question is

async login() {
  const mkInst = MusicKit.getInstance();
  await mkInst.authorize();
}

Not sure if this is limited to V3, as it's technically not officially released, but figured it was worth bringing to attention.

Answered by mhartington in 719821022

For anyone who may experience the same issue here, turns out the library pwacompat was causing issues with the authentication. I haven't dug into what part was causing issues, but removing it from the index.html fixed the issue.

Thank you for reaching out, @mhartington

MusicKit on the Web V3 is expected to be fully functional and production-ready. It is in extended beta to make sure we process developer feedback completely before taking it out of beta. Your code snippet appears valid as well, and we would expect that to work consistently on desktop Safari as well as iPadOS/iOS.

The "cannot parse response" error message in Safari is usually indicative of a client-side network issue, which may be due to the network you are connected to, DNS configuration on the device for a network, a proxy layer, etc. This thread in the Apple Support Community forums may provide more information on resolving that error: Safari cannot parse response.

If you are still having issues, please file a ticket in the Feedback Assistant with more details on steps to reproduce, the versions of the operating system(s) and browser(s) you are experiencing issues with, and a .har export from the network tab using the Web Inspector.

Network settings within the devices are set to automatic, so nothing special there. Safari's History and Website data has been cleared, and all experimental features have been reset to defaults.

Trying to get a network trace might be difficult as the authentication page is opened in a new tab and web inspector is not able to connect until it's already failed to load the page. I will attempt to provide more details in Feedback Assistant.

Accepted Answer

For anyone who may experience the same issue here, turns out the library pwacompat was causing issues with the authentication. I haven't dug into what part was causing issues, but removing it from the index.html fixed the issue.

MusicKit JS v3 authentication failure
 
 
Q