1

whenever I try to authenticate a MusicKit instance the popup alway shows 'Problem Connecting There may be a network issue. '. When reloading the popup it shows the login screen, but after I did log in it shows the same error page again.

On the first error screen I get the following error in the console. A searching for the error it seems to be connect to ember js.

Error while processing route: woa Failed to construct 'URL': Invalid URL TypeError: Failed to construct 'URL': Invalid URL

TypeError: Failed to construct 'URL': Invalid URL

On the second error page I find the following error in the console:

Error while processing route: oauth-screen

This happens both on Brave and Safari.

Is this a bug or did i something wrong?

My Code:

<html>

<head>
    <script src="https://js-cdn.music.apple.com/musickit/v1/musickit.js"></script>
</head>

<body>
    <script>
        document.addEventListener('musickitloaded', function () {
            MusicKit.configure({
                developerToken: 'My token',
                debug: true,
                suppressErrorDialog: false
            });

            let music = MusicKit.getInstance();

            music.authorize().then(function (response) {
                console.log(response);
            });
        });
    </script>
</body>

</html>
CptCookie
  • 11
  • 3
  • Your code looks fine. Note though that there is a new version of the SDK. It's poorly documented, but you can find it here: https://js-cdn.music.apple.com/musickit/v3/docs/index.html?path=/story/introduction--page – Brad Oct 25 '21 at 19:51
  • 1
    Thank you for the link. I tried the newer version, but it is still the same result. I'm currently in contact with Apple's support about this problem and I will give an update as soon as there is any development there. – CptCookie Nov 01 '21 at 11:04
  • @CptCookie any chance this has been resolved? My app suddenly stopped working after 3 years.. – zerohedge Feb 28 '22 at 01:14
  • @zerohedge, for me it was a problem with how I opened the code locally. I assume this is not so helpful for something I presume to be an app in production. Sry, but the apple support was very helpful but also kind of slow in its responses. – CptCookie Mar 01 '22 at 12:33

1 Answers1

0

The Code is fine, but I opened it directly from disk. For an unknown reason, musickit does not like this. It needed to be served via a small HTTP server to work properly.

CptCookie
  • 11
  • 3