MusicKit JS

RSS for tag

Add an Apple Music player to your web app using MusicKit JS.

Posts under MusicKit JS tag

123 Posts

Post

Replies

Boosts

Views

Activity

Apple Music API: only get full Albums from user's library
If a user has only added one song from an album in its library, the library album endpoint (/me/library/albums) will return this album. It does not make sense because the user did not add the full album to its library, only one song. Note that the Apple Music app is doing the same in its Library > Albums section. How to retrieve only those albums which have been added ?
0
0
786
Jul ’23
MusicKitJS | Cannot play explicit songs | CONTENT_RESTRICTED
[Ticket on Feedback Assistant FB12353357] Hi there, We’re experiencing issues playing explicit songs using MusicKitJS for the Web (tested on both stable v1 and beta v3). Upon calling the SDK’s “play()” function, the following error gets logged in the console “CONTENT_RESTRICTED: Content restricted” and playback doesn’t begin. The Storefront we’ve tested in is “it”, but very likely all of them are impacted with the issue, here’s a few Adam IDs of affected tracks: 1681182396, 1683117248, 1669607876. A quick check with the REST APIs reveals indeed that the relevant thing all 3 of them have in common is "contentRating" being "explicit”. The bug isn’t however easy or predictable to replicate because it seems that it can be somewhat solved by fiddling with both the “Screen Time” restrictions settings within an iOS/iPadOS device (of course logged in with the same Apple account), as well as with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page. We’re still not 100% sure what exactly “triggers” the fix, but both mentioned dashboards above are essential in attempting to solve it by trial and error. Specifically: in the “Parental Controls” dashboard what helps is actually turning ON the restrictions with the toggle, and then easing them up the most by specifically setting the less restricted available option in all 3 dropdown menus (pretty baffling); in the “Screen time” dashboard what helps is simply enabling/disabling the feature itself altogether, as well as the “Content & Privacy restrictions” toggle, and changing the level of allowed content between “Clean” and “Explicit”; I also want to highlight the fact that during the entire process, for the issue to be actually solved, users every time had to to restart their iPhone/iPad multiple times after changing a setting in “Screen time”, along with deauthorizing/authorizing (logging out and back in) their Apple Music account from the MusicKitJS SDK. The issue seems to always affect freshly created Apple accounts right from the start, we’re not aware of methods that can lead to the bug “coming back” and starting to happen again after being solved manually with the process above (meddling “randomly” with dashboards). It’s a pretty serious one because many of our users do not posses an Apple device and only use their Apple Music subscription on the Web and/or their Android device, meaning that the “Screen time” dashboard isn’t available for them. We’ve never been able to solve the problem on an Apple ID account solely by fiddling with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page: tinkering with the “Screen time” settings was essential every single time, meaning owning an Apple device is essential to solve it. Last thing I’m adding is that the issue doesn’t seem to also affect listening to these explicit songs directly with the various first-party Apple Music clients (tested on the iOS native app, Android native app, and on the Apple Music WebApp). Steps to reproduce: on the Web, create a new Apple ID account and activate an Apple Music subscription (do not login with said account on an Apple device); go to the Apple Music WebApp settings page at music.apple.com/account/settings and make sure that the “Parental Controls” restrictions are turned OFF; open any explicit song in the Apple Music WebApp and confirm that playback is allowed; login and authorize the newly created account using any website/application integrated with the MusicKitJS SDK (v1 or v3, doesn’t matter); open the same explicit song as before (or any other) in said third-party client that uses the SDK and verify that playback doesn’t begin and an error “CONTENT_RESTRICTED: Content restricted” is logged in the console upon playing. Additional infos: Apple ID account region and language: Italy - Italian; Storefront affected: IT but possibly all of them; MusicKitJS versions affected: both v1 and v3; Browser where the issue was reproduced: Chrome v114. Attached you’ll find some informational screenshots. Thanks!
2
0
1.4k
Jun ’23
Apple Music API Enhancements
Hi, We are a funded startup developing a music festival and concert application that integrates with Apple Music. Two big features the API is missing are PUT and DELETE endpoints for tracks on a playlist. Both of these would drastically enhance the user experience on third-party apps that leverage Apple Music, specifically for editing and curating playlists. We have also noticed many errors returned as 403 when we have literally just signed in with a brand new token. We have confirmed on our end that the token is valid, fresh and can be used through other clients. As well, Apple's MusicKitJS SDK could use a bit of work. We were able to unminify and work around these issues; most of them were addressed with a simple try/catch and retry routine. We love the Apple Music API and SDK, and in general found it super easy to integrate with, setup and use. We also firmly believe Apple puts out superior products to other technology firms in the same industry. It was disappointing to see the API and SDK for Apple Music falling behind compared to other music providers who offer similar API's. We really hope Apple improves and enhances these offerings in the future. Also just wanted to give a shotout and thanks to all of the devs who make these services accessible and the integration possible. We wouldn't be here without you, and didn't want this post to come off as a rant just more of a friendly "nudge."
0
0
1.1k
Jun ’23
Musickit on the web
Hello everyone, I'm currently working on some projects in React that involve using MusicKit on the web. However, I've been having some trouble finding a package that works with React. I've noticed that there's a beta version of MusicKit for web available, but I'm not sure if Apple has released an npm package for it yet. If there isn't an npm package available, is it still possible to use MusicKit on the web using just HTML and JavaScript? I'd appreciate any guidance or advice on how to get started with this. Thank you in advance for your help! Best regards.
0
0
773
May ’23
Can I integrate MusicKit in a SAAS?
Hi, I'm developing a web app that integrates various widgets into a single page to boost users productivity. I would like to link to integrate Apple Music too using the MusicKit JS SDK. I'll monetize the web app through monthly subscriptions. There they get access to all the widgets. So my question is whether it is allowed? If not, is there any other way I can still give my users ability to play Apple Music from the web app? Thanks
0
0
627
May ’23
Does apple music api provide featured artists information of a song?
Hey. now I'm using apple music api to collect music informations. but I've noticed that I couldn't get the featured artists information from a song. guess there's a song Foo - Bar (Feat. Baz). In spotify API, we can retrieve featured artist information something like this: { // ... "artists": [ "Foo", // <-- primary artist "Baz" // <-- featured artist ] // ... } but as I see in documentation, there is no API (or relationship with a song) for get all the artists (including featured artists) of a song. GET https://api.music.apple.com/v1/catalog/kr/songs/1544411971 { "data": [ { // ... "attributes": { // ... "name": "36.5 (feat. Hwaji)", // ... }, "relationships": { // ... "artists": { "href": "/v1/catalog/kr/songs/1544411971/artists", "data": [ { "id": "1297171788", "type": "artists", "href": "/v1/catalog/kr/artists/1297171788" } ] } } } ] } as you can see here, there's only one artist relationship object in artists.data array even if the target song have featuring artist. Is there any way to get featured artists information of a song?
1
0
1.5k
Apr ’23
MusicKit web 403 error issue
Hello! I am currently working on a react.js application that is integrating with the MusicKit v3 library. I have followed the documentation to generate a JWT for MusicKit and add the library to my application. Using my token I am able to successfully retrieve song information from the Apple Music API, but I am having trouble with authentication. When I call music.authorize() and successfully go through the Apple sign in popup, I am receiving the following 403 error: https://play.itunes.apple.com/WebObjects/MZPlay.woa/wa/webPlayerLogout 403 musickit.js:44 Uncaught (in promise) AUTHORIZATION_ERROR: Unauthorized After stepping through the music kit API and login popup with breakpoints, I am seeing that the music user token is null, despite the login popup succeeding and returning a proper token/response: {"isAppleMusicSubscriber":"true","musicUserToken":"Ak4ItOgRRRG2y6xgA/OeWQPK0RqPQ/esAJkRN0B/Ua/AWLT52tLhd2TfzMK6uhH+Nczvd7wjYDM1UewG/NledKtimwlrR+s5tdQPk/FG28zqhBqXZ12q6LC516w8ELZDwv5T61kV8xiJ1KSO1q4pGi01JO7SuPMtOqB/QsycYj+xNnrYUEwlP5tm/zxfg7bWmvuWMwfUruYR+A1U9FdXZsdIITVmxCjiHg8ro9xXRzl6Txhsag\u003d\u003d","cid":"REDACTED","itre":"REDACTED","supported":"REDACTED"} I have tested my application with multiple Apple Music users who have paid subscriptions. All accounts are receiving this same error. I have tried regenerating my JWT token multiple times following various guides. My latest attempt used the following node library and parameters: var jwt = require('jsonwebtoken'); var fs = require('fs'); var privateKey = fs.readFileSync('./AuthKey_MYKEY.p8'); let now = new Date(); let nextMonth = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate()); let nowEpoch = Math.round(now.getTime() / 1000); // number of seconds since Epoch, in UTC let nextMonthEpoch = Math.round(nextMonth.getTime() / 1000); // number of seconds since Epoch, in UTC var payload = {     iss: 'REDACTED', // TEAM ID     iat: nowEpoch,     exp: nextMonthEpoch }; var options = {     algorithm: 'ES256',     header: {         alg: 'ES256',         kid: 'REDACTED' // KEY ID     } }; jwt.sign(payload, privateKey, options, function(error, token) {     console.log(error);     console.log(token); }); I have a valid App Identifier created with the MusicKit App Service enabled. I am stuck! I have no other ideas on the possible root cause here. Is there something I am missing? I have a mobile app currently in Test Flight - does this app need to be released to the app store? I am out of guesses! Any support here would be greatly appreciated! Thank you for your time. Patrick
9
1
3.9k
Mar ’23
Is there a way to get a unique identifier for a user from MusicKit JS?
Hello! I'm trying out MusicKit JS and am able to log in and retrieve songs from my library, but I want to be able to store some information tied to myself as a user between sessions. I can't seem to find any unique identifier for a user besides maybe the musicUserToken?, which I assume will change at some point. I also can't seem to find any direction on how to get any user information like name/apple id/etc. without also getting an auth token from apple id and then sending the id token back for information. I was just thinking, since they already log in to apple to authorize MusicKit JS, there must be some way to get some unique identifier to tie the logged in user to itself across sessions. Am I missing something or do i need to make another call to get an auth token? Thanks
0
0
962
Mar ’23
Authorize to Apple Music via In-App Browser (FB Messanger,Instaram,Twitter))
We're using  https://developer.apple.com/documentation/musickitjs to authorize Apple music, on Desktop it opens a new window to authorize to apple. But It's NOT working on mobile In-App Browser (both iOS &amp; Android), probably because on mobile messenger, it's not possible to allow the opening of multiple windows. Are we missing something here? Any workaround for it? Has anyone done that?
3
0
2.6k
Mar ’23
Is Apple going to stop people from abusing MusicKit developer token taken from music.apple.com
Many developers know that you can easily get a MusicKit developer token from music.apple.com. Just go to the console of the browser and input "MusicKit.getInstance().developerToken". As of now, the token is eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNjQ2NDM1NTgxLCJleHAiOjE2NjE5ODc1ODF9.Ob5bfZBWLDlDkR4r5fNXIjp1Y1G0qY5mP9MVBm1mDFjG701_6AcZS6nwjk-CMJE2b8VLv1JWxKR5j5BDkKxQ7w This token is not like the one we developers generate ourselves that has many limitations. Instead, it is a privileged one that has some powerful features and is able to invoke some "private" API as follows: Deleting users' resources (for example, DELETE method on https://amp-api.music.apple.com/v1/me/library/songs/{id}) Getting and showing lyrics Rename playlist, reordering songs in a playlist Many other features that music.apple.com could do but your apps couldn't I think it's fine to use it privately and do not be evil, but Apple failed to stop people from abusing it. I already spotted one app selling on Microsoft Apps Store(https://apps.microsoft.com/store/detail/cider-alpha/9P21XJ9D9G66) that is taking advantage of this "privileged" token. Proofs are as follows: fetch the privileged developer token https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L3665 removeFromLibrary https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2254 load official AM lyrics https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2237 They get the token for free, take the source code from music.apple.com with some modification, put it into an electron app. Then sell it and beat other competitor apps because it's more "powerful". And this makes me a developer obeying the rules like a stupid fool because I pay $99 for ADP to get the developer token, while they get it for free I got a token that has limited features, while theirs are far more powerful I already submitted it to Apple but got no response. Apple should really start to do something, otherwise It's like telling every developer that: Stop paying $99 for ADP to get your developer token, just grab it from music.apple.com. It's free yet super powerful to call private APIs and bypass limitations.
9
0
7.2k
Feb ’23
Apple Music Terms of Use / Guidelines
Hi, I'm working on a web application that uses Apple Music API, but after reading the terms of use and guidelines, it's still shady if what I want to achieve is allowed or not. The core functionality is: users are able to host a "listen party" where everyone can listen to the same song together (using their subscription, no streaming). Just the host can control the music playback. The web app is "freemium". This means that free and paid users can access the same content, there's no paywall. What are the gotchas, in regards to the Terms of Use and Guidelines, when it comes to an app like the one I've just mentioned? What about the copyrights related to the artists/songs? Best Regards, Ricardo
1
0
1.2k
Jan ’23
MusicKit JS v1 token not set in storage
Hello! I'm working to integrate my web application with MusicKit JS. I am experiencing an issue with the authentication flow where the proper localStorage key is not set with the music token after authenticating successfully. The expected output after going through the authentication flow is a localStorage key to be set with a name similar to "music.r4p2h4kf4l.u". I have tested my developer token using a simple HTML file, and after successfully authenticating, the localStorage key is set successfully. My web application that I am developing and experiencing this issue on is built using strapi/reactjs. I have dug into this issue much deeper in the vendor JS code and have possibly narrowed the issue down to immediately after inputting the 6 digit security code. When testing using my simple JS file, a sessionStorage key named "ac" is set to my app's URL (in this example, localhost:3000). When I test using my strapi/react application, this sessionStorage key is not set, and thus I believe this is preventing calls to postMessage and localStorage to not function properly. I have confirmed that when initially opening the auth dialog, the /woa endpoint is called and the referrer parameter is properly set. Does anyone have any idea why this wouldn't work for a reactjs/strapi app? My actual authentication is succeeding and I see a music user token being successfully retrieved in the console within the auth popup. I have spent a lot of time on this and am running out of ideas!
1
0
1.2k
Jan ’23
How to query for an artists latest release using Apple Music API
Hi all - quick question regarding the Apple Music API. I would like to query for an artists most recent album so that I can feature that release more prominently within my app. Looking at the API docs, I could hit an endpoint such as this: https://api.music.apple.com/v1/catalog/us/artists/669831761/albums and that would return all the albums related to that artist. However, it appears that the albums aren't sorted in chronological order, so it seems that I would have to paginate through every page and sort these results to find the most recent release. Is there a better method? I feel like this is a very ineffective practice and would like to hear any possible alternatives, thank you!
2
0
1.9k
Dec ’22
MusicKit playlist creation fails when number of songs is too large
I'm creating a playlist using the MusicKit endpoint and its failing with a generic error when I give it too many songs. [DataRequesting] Failed to perform MusicDataRequest.Context(  url: "https://api.music.apple.com/v1/me/library/playlists",  currentRetryCounts: [.other: 1] ) with MusicDataRequest.Error(  status: 500,  code: 50001,  title: "Upstream Service Error",  detailText: "Service failure: Cloud Library",  id: "NX5X43DEV3KH5NEK3Q7CEHJENM",  originalResponse: MusicDataResponse(   data: 153 bytes,   urlResponse: <NSHTTPURLResponse: 0x0000000280220080>  ) ). I tried setting a maximum of 500 songs and the request succeeded. Is there a known limit to how many songs can be added at once?
1
0
1.7k
Dec ’22
Apple Music API: only get full Albums from user's library
If a user has only added one song from an album in its library, the library album endpoint (/me/library/albums) will return this album. It does not make sense because the user did not add the full album to its library, only one song. Note that the Apple Music app is doing the same in its Library > Albums section. How to retrieve only those albums which have been added ?
Replies
0
Boosts
0
Views
786
Activity
Jul ’23
Developer copy of Logic X
Hello Everyone, We've had an idea for a hardware controller for Logic X, and have already made prototypes that work with Garage Band and other applications. My question is - Does Apple have a development license available for Logic X? Thanks.
Replies
1
Boosts
1
Views
766
Activity
Jul ’23
MusicKitJS | Cannot play explicit songs | CONTENT_RESTRICTED
[Ticket on Feedback Assistant FB12353357] Hi there, We’re experiencing issues playing explicit songs using MusicKitJS for the Web (tested on both stable v1 and beta v3). Upon calling the SDK’s “play()” function, the following error gets logged in the console “CONTENT_RESTRICTED: Content restricted” and playback doesn’t begin. The Storefront we’ve tested in is “it”, but very likely all of them are impacted with the issue, here’s a few Adam IDs of affected tracks: 1681182396, 1683117248, 1669607876. A quick check with the REST APIs reveals indeed that the relevant thing all 3 of them have in common is "contentRating" being "explicit”. The bug isn’t however easy or predictable to replicate because it seems that it can be somewhat solved by fiddling with both the “Screen Time” restrictions settings within an iOS/iPadOS device (of course logged in with the same Apple account), as well as with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page. We’re still not 100% sure what exactly “triggers” the fix, but both mentioned dashboards above are essential in attempting to solve it by trial and error. Specifically: in the “Parental Controls” dashboard what helps is actually turning ON the restrictions with the toggle, and then easing them up the most by specifically setting the less restricted available option in all 3 dropdown menus (pretty baffling); in the “Screen time” dashboard what helps is simply enabling/disabling the feature itself altogether, as well as the “Content & Privacy restrictions” toggle, and changing the level of allowed content between “Clean” and “Explicit”; I also want to highlight the fact that during the entire process, for the issue to be actually solved, users every time had to to restart their iPhone/iPad multiple times after changing a setting in “Screen time”, along with deauthorizing/authorizing (logging out and back in) their Apple Music account from the MusicKitJS SDK. The issue seems to always affect freshly created Apple accounts right from the start, we’re not aware of methods that can lead to the bug “coming back” and starting to happen again after being solved manually with the process above (meddling “randomly” with dashboards). It’s a pretty serious one because many of our users do not posses an Apple device and only use their Apple Music subscription on the Web and/or their Android device, meaning that the “Screen time” dashboard isn’t available for them. We’ve never been able to solve the problem on an Apple ID account solely by fiddling with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page: tinkering with the “Screen time” settings was essential every single time, meaning owning an Apple device is essential to solve it. Last thing I’m adding is that the issue doesn’t seem to also affect listening to these explicit songs directly with the various first-party Apple Music clients (tested on the iOS native app, Android native app, and on the Apple Music WebApp). Steps to reproduce: on the Web, create a new Apple ID account and activate an Apple Music subscription (do not login with said account on an Apple device); go to the Apple Music WebApp settings page at music.apple.com/account/settings and make sure that the “Parental Controls” restrictions are turned OFF; open any explicit song in the Apple Music WebApp and confirm that playback is allowed; login and authorize the newly created account using any website/application integrated with the MusicKitJS SDK (v1 or v3, doesn’t matter); open the same explicit song as before (or any other) in said third-party client that uses the SDK and verify that playback doesn’t begin and an error “CONTENT_RESTRICTED: Content restricted” is logged in the console upon playing. Additional infos: Apple ID account region and language: Italy - Italian; Storefront affected: IT but possibly all of them; MusicKitJS versions affected: both v1 and v3; Browser where the issue was reproduced: Chrome v114. Attached you’ll find some informational screenshots. Thanks!
Replies
2
Boosts
0
Views
1.4k
Activity
Jun ’23
Apple Music API Enhancements
Hi, We are a funded startup developing a music festival and concert application that integrates with Apple Music. Two big features the API is missing are PUT and DELETE endpoints for tracks on a playlist. Both of these would drastically enhance the user experience on third-party apps that leverage Apple Music, specifically for editing and curating playlists. We have also noticed many errors returned as 403 when we have literally just signed in with a brand new token. We have confirmed on our end that the token is valid, fresh and can be used through other clients. As well, Apple's MusicKitJS SDK could use a bit of work. We were able to unminify and work around these issues; most of them were addressed with a simple try/catch and retry routine. We love the Apple Music API and SDK, and in general found it super easy to integrate with, setup and use. We also firmly believe Apple puts out superior products to other technology firms in the same industry. It was disappointing to see the API and SDK for Apple Music falling behind compared to other music providers who offer similar API's. We really hope Apple improves and enhances these offerings in the future. Also just wanted to give a shotout and thanks to all of the devs who make these services accessible and the integration possible. We wouldn't be here without you, and didn't want this post to come off as a rant just more of a friendly "nudge."
Replies
0
Boosts
0
Views
1.1k
Activity
Jun ’23
MusicKit JS throwing net::ERR_FILE_NOT_FOUND
There are a couple of tracks that recently are throwing an net::ERR_FILE_NOT_FOUND error in console. All other songs are playing music just fine. One ID in question: 1685732269
Replies
0
Boosts
0
Views
726
Activity
May ’23
Musickit on the web
Hello everyone, I'm currently working on some projects in React that involve using MusicKit on the web. However, I've been having some trouble finding a package that works with React. I've noticed that there's a beta version of MusicKit for web available, but I'm not sure if Apple has released an npm package for it yet. If there isn't an npm package available, is it still possible to use MusicKit on the web using just HTML and JavaScript? I'd appreciate any guidance or advice on how to get started with this. Thank you in advance for your help! Best regards.
Replies
0
Boosts
0
Views
773
Activity
May ’23
Can I integrate MusicKit in a SAAS?
Hi, I'm developing a web app that integrates various widgets into a single page to boost users productivity. I would like to link to integrate Apple Music too using the MusicKit JS SDK. I'll monetize the web app through monthly subscriptions. There they get access to all the widgets. So my question is whether it is allowed? If not, is there any other way I can still give my users ability to play Apple Music from the web app? Thanks
Replies
0
Boosts
0
Views
627
Activity
May ’23
Delete/Remove song (Apple Music For artist)
How can I remove my songs on Apple Music for artist as admin. Is it possible to delete/remove uploaded song on Apple Music for artist.
Replies
1
Boosts
0
Views
853
Activity
Apr ’23
[Apple Music API] What are extended attributes?
In many request you can include "extend" parameters. But there is nowhere list of extended attributes that I can apply to the request. I tried using various option but results are the same as without them.
Replies
1
Boosts
3
Views
1.6k
Activity
Apr ’23
Does apple music api provide featured artists information of a song?
Hey. now I'm using apple music api to collect music informations. but I've noticed that I couldn't get the featured artists information from a song. guess there's a song Foo - Bar (Feat. Baz). In spotify API, we can retrieve featured artist information something like this: { // ... "artists": [ "Foo", // <-- primary artist "Baz" // <-- featured artist ] // ... } but as I see in documentation, there is no API (or relationship with a song) for get all the artists (including featured artists) of a song. GET https://api.music.apple.com/v1/catalog/kr/songs/1544411971 { "data": [ { // ... "attributes": { // ... "name": "36.5 (feat. Hwaji)", // ... }, "relationships": { // ... "artists": { "href": "/v1/catalog/kr/songs/1544411971/artists", "data": [ { "id": "1297171788", "type": "artists", "href": "/v1/catalog/kr/artists/1297171788" } ] } } } ] } as you can see here, there's only one artist relationship object in artists.data array even if the target song have featuring artist. Is there any way to get featured artists information of a song?
Replies
1
Boosts
0
Views
1.5k
Activity
Apr ’23
MusicKit web 403 error issue
Hello! I am currently working on a react.js application that is integrating with the MusicKit v3 library. I have followed the documentation to generate a JWT for MusicKit and add the library to my application. Using my token I am able to successfully retrieve song information from the Apple Music API, but I am having trouble with authentication. When I call music.authorize() and successfully go through the Apple sign in popup, I am receiving the following 403 error: https://play.itunes.apple.com/WebObjects/MZPlay.woa/wa/webPlayerLogout 403 musickit.js:44 Uncaught (in promise) AUTHORIZATION_ERROR: Unauthorized After stepping through the music kit API and login popup with breakpoints, I am seeing that the music user token is null, despite the login popup succeeding and returning a proper token/response: {"isAppleMusicSubscriber":"true","musicUserToken":"Ak4ItOgRRRG2y6xgA/OeWQPK0RqPQ/esAJkRN0B/Ua/AWLT52tLhd2TfzMK6uhH+Nczvd7wjYDM1UewG/NledKtimwlrR+s5tdQPk/FG28zqhBqXZ12q6LC516w8ELZDwv5T61kV8xiJ1KSO1q4pGi01JO7SuPMtOqB/QsycYj+xNnrYUEwlP5tm/zxfg7bWmvuWMwfUruYR+A1U9FdXZsdIITVmxCjiHg8ro9xXRzl6Txhsag\u003d\u003d","cid":"REDACTED","itre":"REDACTED","supported":"REDACTED"} I have tested my application with multiple Apple Music users who have paid subscriptions. All accounts are receiving this same error. I have tried regenerating my JWT token multiple times following various guides. My latest attempt used the following node library and parameters: var jwt = require('jsonwebtoken'); var fs = require('fs'); var privateKey = fs.readFileSync('./AuthKey_MYKEY.p8'); let now = new Date(); let nextMonth = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate()); let nowEpoch = Math.round(now.getTime() / 1000); // number of seconds since Epoch, in UTC let nextMonthEpoch = Math.round(nextMonth.getTime() / 1000); // number of seconds since Epoch, in UTC var payload = {     iss: 'REDACTED', // TEAM ID     iat: nowEpoch,     exp: nextMonthEpoch }; var options = {     algorithm: 'ES256',     header: {         alg: 'ES256',         kid: 'REDACTED' // KEY ID     } }; jwt.sign(payload, privateKey, options, function(error, token) {     console.log(error);     console.log(token); }); I have a valid App Identifier created with the MusicKit App Service enabled. I am stuck! I have no other ideas on the possible root cause here. Is there something I am missing? I have a mobile app currently in Test Flight - does this app need to be released to the app store? I am out of guesses! Any support here would be greatly appreciated! Thank you for your time. Patrick
Replies
9
Boosts
1
Views
3.9k
Activity
Mar ’23
Is there a way to get a unique identifier for a user from MusicKit JS?
Hello! I'm trying out MusicKit JS and am able to log in and retrieve songs from my library, but I want to be able to store some information tied to myself as a user between sessions. I can't seem to find any unique identifier for a user besides maybe the musicUserToken?, which I assume will change at some point. I also can't seem to find any direction on how to get any user information like name/apple id/etc. without also getting an auth token from apple id and then sending the id token back for information. I was just thinking, since they already log in to apple to authorize MusicKit JS, there must be some way to get some unique identifier to tie the logged in user to itself across sessions. Am I missing something or do i need to make another call to get an auth token? Thanks
Replies
0
Boosts
0
Views
962
Activity
Mar ’23
Authorize to Apple Music via In-App Browser (FB Messanger,Instaram,Twitter))
We're using  https://developer.apple.com/documentation/musickitjs to authorize Apple music, on Desktop it opens a new window to authorize to apple. But It's NOT working on mobile In-App Browser (both iOS &amp; Android), probably because on mobile messenger, it's not possible to allow the opening of multiple windows. Are we missing something here? Any workaround for it? Has anyone done that?
Replies
3
Boosts
0
Views
2.6k
Activity
Mar ’23
Is Apple going to stop people from abusing MusicKit developer token taken from music.apple.com
Many developers know that you can easily get a MusicKit developer token from music.apple.com. Just go to the console of the browser and input "MusicKit.getInstance().developerToken". As of now, the token is eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNjQ2NDM1NTgxLCJleHAiOjE2NjE5ODc1ODF9.Ob5bfZBWLDlDkR4r5fNXIjp1Y1G0qY5mP9MVBm1mDFjG701_6AcZS6nwjk-CMJE2b8VLv1JWxKR5j5BDkKxQ7w This token is not like the one we developers generate ourselves that has many limitations. Instead, it is a privileged one that has some powerful features and is able to invoke some "private" API as follows: Deleting users' resources (for example, DELETE method on https://amp-api.music.apple.com/v1/me/library/songs/{id}) Getting and showing lyrics Rename playlist, reordering songs in a playlist Many other features that music.apple.com could do but your apps couldn't I think it's fine to use it privately and do not be evil, but Apple failed to stop people from abusing it. I already spotted one app selling on Microsoft Apps Store(https://apps.microsoft.com/store/detail/cider-alpha/9P21XJ9D9G66) that is taking advantage of this "privileged" token. Proofs are as follows: fetch the privileged developer token https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L3665 removeFromLibrary https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2254 load official AM lyrics https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2237 They get the token for free, take the source code from music.apple.com with some modification, put it into an electron app. Then sell it and beat other competitor apps because it's more "powerful". And this makes me a developer obeying the rules like a stupid fool because I pay $99 for ADP to get the developer token, while they get it for free I got a token that has limited features, while theirs are far more powerful I already submitted it to Apple but got no response. Apple should really start to do something, otherwise It's like telling every developer that: Stop paying $99 for ADP to get your developer token, just grab it from music.apple.com. It's free yet super powerful to call private APIs and bypass limitations.
Replies
9
Boosts
0
Views
7.2k
Activity
Feb ’23
How to set music user token expiration?
I would like to create presave feature on my app with Apple Music API. On this article, developer token has an option to set expiration date but music user token don't. Does music user token has an option to set expiration date? If not, how do I know expiration date on music user token?
Replies
2
Boosts
0
Views
2.3k
Activity
Feb ’23
When does a Music User token expire?
After how much time does a Music User token expire? For my use case I am unable to reauth the user using MusicKit JS, so I would like to know how long I can use the User token.
Replies
2
Boosts
0
Views
2k
Activity
Feb ’23
Apple Music Terms of Use / Guidelines
Hi, I'm working on a web application that uses Apple Music API, but after reading the terms of use and guidelines, it's still shady if what I want to achieve is allowed or not. The core functionality is: users are able to host a "listen party" where everyone can listen to the same song together (using their subscription, no streaming). Just the host can control the music playback. The web app is "freemium". This means that free and paid users can access the same content, there's no paywall. What are the gotchas, in regards to the Terms of Use and Guidelines, when it comes to an app like the one I've just mentioned? What about the copyrights related to the artists/songs? Best Regards, Ricardo
Replies
1
Boosts
0
Views
1.2k
Activity
Jan ’23
MusicKit JS v1 token not set in storage
Hello! I'm working to integrate my web application with MusicKit JS. I am experiencing an issue with the authentication flow where the proper localStorage key is not set with the music token after authenticating successfully. The expected output after going through the authentication flow is a localStorage key to be set with a name similar to "music.r4p2h4kf4l.u". I have tested my developer token using a simple HTML file, and after successfully authenticating, the localStorage key is set successfully. My web application that I am developing and experiencing this issue on is built using strapi/reactjs. I have dug into this issue much deeper in the vendor JS code and have possibly narrowed the issue down to immediately after inputting the 6 digit security code. When testing using my simple JS file, a sessionStorage key named "ac" is set to my app's URL (in this example, localhost:3000). When I test using my strapi/react application, this sessionStorage key is not set, and thus I believe this is preventing calls to postMessage and localStorage to not function properly. I have confirmed that when initially opening the auth dialog, the /woa endpoint is called and the referrer parameter is properly set. Does anyone have any idea why this wouldn't work for a reactjs/strapi app? My actual authentication is succeeding and I see a music user token being successfully retrieved in the console within the auth popup. I have spent a lot of time on this and am running out of ideas!
Replies
1
Boosts
0
Views
1.2k
Activity
Jan ’23
How to query for an artists latest release using Apple Music API
Hi all - quick question regarding the Apple Music API. I would like to query for an artists most recent album so that I can feature that release more prominently within my app. Looking at the API docs, I could hit an endpoint such as this: https://api.music.apple.com/v1/catalog/us/artists/669831761/albums and that would return all the albums related to that artist. However, it appears that the albums aren't sorted in chronological order, so it seems that I would have to paginate through every page and sort these results to find the most recent release. Is there a better method? I feel like this is a very ineffective practice and would like to hear any possible alternatives, thank you!
Replies
2
Boosts
0
Views
1.9k
Activity
Dec ’22
MusicKit playlist creation fails when number of songs is too large
I'm creating a playlist using the MusicKit endpoint and its failing with a generic error when I give it too many songs. [DataRequesting] Failed to perform MusicDataRequest.Context(  url: "https://api.music.apple.com/v1/me/library/playlists",  currentRetryCounts: [.other: 1] ) with MusicDataRequest.Error(  status: 500,  code: 50001,  title: "Upstream Service Error",  detailText: "Service failure: Cloud Library",  id: "NX5X43DEV3KH5NEK3Q7CEHJENM",  originalResponse: MusicDataResponse(   data: 153 bytes,   urlResponse: <NSHTTPURLResponse: 0x0000000280220080>  ) ). I tried setting a maximum of 500 songs and the request succeeded. Is there a known limit to how many songs can be added at once?
Replies
1
Boosts
0
Views
1.7k
Activity
Dec ’22