0 Replies
      Latest reply on May 17, 2019 4:40 AM by server@3bweb.com
      server@3bweb.com Level 1 Level 1 (0 points)

        My basic script will not work. When I click the button it should play as all documentation tells me

         

        <html>

        <head>

            <meta name="apple-music-app-name" content="Gramophone Music">

        <meta name="apple-music-app-build" content="1978.4.1">

        <meta name="apple-music-developer-token" content="<DEVELOPER TOKEN>">

         

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

        </head>

        <body>

        <button data-apple-music-set-queue="https://itunes.apple.com/gb/playlist/dance-nation/pl.8cf5ae2b303642b1a43c8beda7c26d4f">Dance</button>

        </body>

        </html>

         

         

        Instead I get the errors in the console:

         

        GET https://api.music.apple.com/v1/catalog/gb/playlists?ids=pl.8cf5ae2b303642b1a43c8beda7c26d4f 401

        Uncaught (in promise) UNAUTHORIZED_ERROR: 401

            at Function.MKError.responseError (https://js-cdn.music.apple.com/musickit/v1/musickit.js:1:25592)

            at API.<anonymous> (https://js-cdn.music.apple.com/musickit/v1/musickit.js:1:96686)

            at https://js-cdn.music.apple.com/musickit/v1/musickit.js:1:14467

            at Object.throw (https://js-cdn.music.apple.com/musickit/v1/musickit.js:1:14572)

            at rejected (https://js-cdn.music.apple.com/musickit/v1/musickit.js:1:13351)

         

        Is it because of my Developer Token. It seems to be different every time the script is run

         

        const fs      = require("fs");

        const jwt    = require("jsonwebtoken");

         

        const privateKey = fs.readFileSync("Authkey_<key id>.p8").toString();

        const teamId    = "<team id>";

        const keyId      = "<key id>";

         

        const jwtToken = jwt.sign({}, privateKey, {

          algorithm: "ES256",

          expiresIn: "180d",

          issuer: teamId,

          header: {

            alg: "ES256",

            kid: keyId,

            iss: teamId

          }

        });