Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create a Apple Music User Token outside iOS

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/macOS/tvOS/etc.

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!

like image 328
Reinier Avatar asked Jul 18 '17 09:07

Reinier


People also ask

How do I get a user token for my music?

To generate the user token (a MusicKit private key in a *. p8 file, a 10-digit key identifier in your Apple Developer account and your 10-digit Apple Developer Account Team ID), you can visit Apple member centre. If you have a member account, you can proceed with the generating the stuffs.

How do I get Apple Developer Token?

There are two paths to generate developer tokens: If you're developing an app for Apple platforms (iOS, tvOS, watchOS or macOS), the recommended way to integrate with Apple Music is to use MusicKit for Swift, following the steps provided in Using Automatic Developer Token Generation for Apple Music API.

Is Apple Music API free?

Price: The API is offered free to participants in the Apple's Affiliate Program, which allows them to earn commissions on any qualifying sales. Popularity: Apple Music is a popular service around the world, especially for iOS users.

What is an Apple token?

Tokens are physical devices built in to the system, located on attached hardware (like a smart card), or accessible through a network connection. Tokens store cryptographic objects like keys and certificates.


2 Answers

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);
  });
});
like image 174
Kole Myers Avatar answered Oct 03 '22 10:10

Kole Myers


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.

like image 22
Abdul Yasin Avatar answered Oct 03 '22 11:10

Abdul Yasin