anaclumos / now-playing

What is Sunghyun listening to right now? (Apple Music)
https://cho.sh/r/62764C
8 stars 1 forks source link

Unable to get media token using your sample app #1

Open johntdyer opened 1 year ago

johntdyer commented 1 year ago

I do the auth dance here by serving the file from python

python3 -m http.server 9000

the html file is as follows:

<!DOCTYPE html>
<html lang="en">
   <head>
     <meta charset="UTF-8" >
       <meta http-equiv="X-UA-Compatible" content="IE=edge" >
        <meta name="viewport" content="width-device-width, initial-scale=1.0">

      <title>Document</title>
      <script src="https://js-cdn.music.apple.com/musickit/v3/musickit.js" data-web-components async></script>
      <script>
         document.addEventListener('musickitloaded', async function () {
          try {
            await MusicKit.configure({
               developerToken: 'sxxxxxxx',
                app: {
                  name: 'Dynamic Island on the Web',
                  build: '2021.1.0',
                },
              })
          } catch (err) {
            // Handle configuration error
            console.error(err)
          }
          const music = MusicKit.getInstance()
          const player = music.player
          await music.authorize()
          await music.play()

          const { data: result } = await music.api.music('/v1/me/library/albums')
          console.log(result.data)
        })
        </script>
      </html>
      </head>
      <body></body>
    </html>

I of course use the dev token returned from this project.

Its not clear to me which point in the auth popup and 2FA I am supposed to see that request but so far I havent found it w/ the media header you expect in your script....

anaclumos commented 1 year ago

Apple made a breaking change on their side and I don’t think it works anymore. Maybe I can reverse-engineer it again but didn’t try it.