2

I'm attempting to access my personal Apple Music library using the MusicKit API. I'm building a Python web application that uses it. I wasn't sure how I could generate a personalized Apple Music User Token. The process appears to be a tad more convoluted than the process for a Developer Token.

I'm also unfamiliar with XCode and Swift - I'd appreciate some hand-holding if the solution requires those.

Thanks!

Mukul Ram
  • 356
  • 4
  • 14

2 Answers2

2

When you are using MusicKit JS there is a undocumented way to retrieve Music User Token. You need to load script on your main html page containg code:

document.addEventListener('musickitloaded', function() {
  // MusicKit global is now defined
  MusicKit.configure({
    developerToken: 'some-token-here',
    app: {
      name: 'your app name',
      build: '1'
    }
  });
console.log("Zaladowano");
let music = MusicKit.getInstance();

music.authorize().then(function(response) {
   console.log(response);
 });

});

Most of the tutorials will tell you to use promise after authorise,but nobody tell you that this callback can have arguments. In this case response is just music user token itself.

Sebastian
  • 448
  • 4
  • 14
1

An Apple Music User Token is returned to your application when the user authorizes your application to have access to the users Apple Music account.

For Native applications, this is done using StoreKit

For Web applications, you could use MusicKit JS. This handles authentication / authorization, and provides access to the library API's in the browser.

Jae Hess
  • 141
  • 1
  • 5
  • Does that mean there's no specific way, even using MusicKit JS, to pull a specific user's personalized music token to access their library? – Mukul Ram Jun 15 '18 at 21:50
  • The user music token appear in http headers for user library related requests of MusicKit js. Maybe you can pull it from there after the user authentification and then use it with Apple Music http API. – FKDev Aug 25 '18 at 09:14