How to Make a JWT (JSON Web Token) for Apple's MusicKit

Опубликовано: 01 Январь 1970
на канале: Get Swifty
4,719
67

#swiftui #iosdev #musickit

UPDATE!
As of WWDC 2021, this is no longer required. Apple have now added the ability to automatically create developer and user tokens. WOOO!



In this video I show you how to generate the JWT (JSON Web Token) that you need for MusicKit within your app. I think Apple expects us to perform this on our own servers and pass them along to the app.

If your music player app doesn't have a server side component (Firebase, iCloud, Vapor, etc) you're in a bit of a pickle. Even with regular app updates, users stuck on an older version of your app will not be able to use the Apple Music features in it once the token expires :(

So the easiest (and least secure way) is to generate these tokens on the device. All you need to do is follow this video, and run your generate token code anytime the JWT is due to a refresh! Heck, run it every time you launch your app if you like.

(Apple should really fix this)

00:00 - Intro
00:29 - New Project
01:38 - Install Swift-JWT Package
02:00 - Generate token with Swift-JWT
03:25 - Outro

Apple docs relating to MusicKit tokens
https://developer.apple.com/documenta...

Stackoverflow answer that helped me out!
https://stackoverflow.com/a/56630546/...

🧑‍💻 Kitura/IBM SwiftJWT package
https://github.com/Kitura/Swift-JWT

---------------------
Want to chat or ask questions about Swift or a career in software development?

Discord
  / discord  

Patreon - Get my book and code created on this channel!
  / beaunouvelle  

Play tabletop games? I made a music and sound effects app for you called Summoning Stone.
https://apps.apple.com/app/apple-stor...

------------------

#swiftui #iosdeveloper #swiftuitutorial


Смотрите видео How to Make a JWT (JSON Web Token) for Apple's MusicKit онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Get Swifty 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4,719 раз и оно понравилось 67 людям.