How to Create a Apple Music User Token outside iOS

℡╲_俬逩灬. 提交于 2019-12-06 03:45:46

问题


I am trying to let people like tracks, albums or playlists on Apple Music from a webpage.

I understand the manual on this page: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/AppleMusicWebServicesReference/SetUpWebServices.html

Until I hit the part where I should use the requestUserToken(forDeveloperToken:completionHandler:) method from SKCloudServiceController in the StoreKit framework, since there is no StoreKit framework available for outside iOS.

How is this token generated? Is there any other way I can generate this Music User Token manually?

I know it is a (very) longshot, but maybe someone figured it out!


回答1:


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.




回答2:


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);
  });
});



回答3:


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.



来源:https://stackoverflow.com/questions/45162986/how-to-create-a-apple-music-user-token-outside-ios

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