Authentication in MusicKit for Swift

MusicKit for Swift makes it far easier to authenticate. No hassle of generating a JWT.

Rudrank Riyam
MusadoraKit
2 min readAug 21, 2021

--

MusicKit for Swift

The first part of the series is on authenticating yourself as a developer of the Apple Developer Program. Earlier, it used to be a long process and was a pain. Now, with MusicKit, it is as simple as a checkmark.

Old Way

Summarising the older process -

  • Register a new key with MusicKit service enabled.
  • Use this key to generate a JSON web token.
  • Send a header with the JWT for every Apple Music API request.
  • For accessing the user’s library, generate a user token as well.

I found the whole process complicated and confusing. I tried my best to simplify the steps in the article Build a Music Chat iOS App Using SwiftUI, but it still felt like a lot of work.

New Way

All you’ve to do is check MusicKit under Services for your bundle identifier.

Apple Developer Portal

That’s it.

No private key.

No JWT.

There’s no need to generate a developer or user token. They’re automatically generated. So, with this, MusicKit also eliminates the risk of committing and exposing your token to version control.

I find it a fantastic improvement. We don’t have to worry about tokens anymore and instead focus on using the new APIs instead.

--

--

Rudrank Riyam
MusadoraKit

Apple Platforms Developer. Technical Writer & Author. Conference Speaker. WWDC '19 Scholar.