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!
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.