How to Create a Apple Music User Token outside iOS

这一生的挚爱 提交于 2019-12-04 08:09:41

I have tried the approach within my iOS app.

You can follow this link generate music token

This is basically python script. You can easily create a music developer token from your mac.

The new Apple MusicKit JS library allows you to create Music User Token's from your Developer Token as seen here outside of iOS. Once you've loaded the Library you can use the authorize method to allow a user to authenticate and generate a token.

document.addEventListener('musickitloaded', function() {
  // MusicKit global is now defined
  MusicKit.configure({
    developerToken: 'DEVELOPER-TOKEN',
    app: {
      name: 'My Cool Web App',
      build: '1978.4.1'
    }
  });

  let music = MusicKit.getInstance();

  music.authorize().then(musicUserToken => {
    console.log(musicUserToken);
  });
});

It’s not possible to obtain a user token from outside the iOS SDK. If you want to interact with a user’s Apple Music library you will need to do this on an iOS device using the StoreKit SDK.

However, you only need this token to interact with a user’s library. It is not needed for querying the Apple Music catalog APIs. For this you only need a developer token which can be generated from your certificate.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!