MusicCatalogSearchRequest without AppleID/Account on iPhone

Hi, I'm currently working on a little music app PoC. I want to search the albums in the Apple Music Catalog which will done via a MusicCatalogSearchRequest:

let musicAuthorizationStatus = await MusicAuthorization.request()
print(musicAuthorizationStatus)

// Issue a catalog search request for albums matching search term.
var searchRequest = MusicCatalogSearchRequest(term: searchTerm, types: [Album.self])
searchRequest.limit = 5
let searchResponse = try? await searchRequest.response()

print(searchResponse?.albums)

I would expect to get a valid search response but it is nil instead.

This is the console log when no AppleID is configured on my test device:

2021-06-15 23:07:19.083194+0200 ShareFi[1519:727518] [Entitlements] MSVEntitlementUtilities - Process ShareFi PID[1519] - Group: com.apple.private.tcc.allow - Entitlement: kTCCServiceMediaLibrary - Entitled: NO - Error: (null)

.authorized

2021-06-15 23:07:19.130446+0200 ShareFi[1519:727542] [DataRequesting] Failed retrieving MusicKit tokens: Error Domain=ICErrorDomain Code=-8102 "Failed to fetch user token." UserInfo={NSDebugDescription=Failed to fetch user token., NSUnderlyingError=0x2825d8750 {Error Domain=ICErrorDomain Code=-7401 "No active account." UserInfo={NSDebugDescription=No active account.}}}. Throwing .userTokenRequestFailed.

2021-06-15 23:07:19.131133+0200 ShareFi[1519:727542] [DataRequesting] Failed retrieving tokens for MusicDataRequest.Context(url: https://api.music.apple.com/v1/catalog/us/search?term=Earfood&types=albums&omit%5Bresource%5D=autos&limit=5). Error = .userTokenRequestFailed.

When I use a sandbox account the error is still a .userTokenRequestFailed but the message says something like: Privacy terms must be accepted first.

The Apple Music API seems to require a "Developer Token" but no "User Token" for search requests?!

So my questions are:

  • Is it possible to make MusicCatalogSearchRequests without having an AppleID configured?
  • What resources can a user without a active Apple Music subscription interact with?

Best regards :) Julian

Accepted Reply

Hello @juka1205,

Thank you very much for the feedback on MusicKit for Swift.

We definitely intend for MusicCatalogSearchRequest to be usable without an active Apple Music subscription.

We are investigating this issue.

Best regards,

  • Awesome! Thx for your quick response ☺️

Add a Comment

Replies

Hello @juka1205,

Thank you very much for the feedback on MusicKit for Swift.

We definitely intend for MusicCatalogSearchRequest to be usable without an active Apple Music subscription.

We are investigating this issue.

Best regards,

  • Awesome! Thx for your quick response ☺️

Add a Comment

Hello @juka1205,

We made changes in iOS 15 beta 3 to be able to use MusicCatalogSearchRequest without an active Apple Music subscription.

I hope this helps.

Best regards,

Hi @JoeKun,

thx for your response! Awesome to see the „live progress“ of your work… ☺️

Best regards Julian