Search code examples
apple-musicapple-musickitapple-musickit-js

Do Apple Music User Tokens expire?


I'm working on integrating Apple Music into my web app. I let users authenticate once, using Apple's MusicKit JS. However, I'm curious if the resulting Music User Token expires. I'm storing this token in a database, but I need to know if I can use this token again at a later date without having the user authenticate again.

This question seems to be semi-related.

Thanks!


Solution

  • After taking a cursory look around, I've found two different questions in the Apple developer forums suggesting that there is a non-configurable 6-month expiration of these tokens. One of these posts was answered by an Apple Media Engineer 2 months ago, which seems about as authoritative a source as you can get outside of documentation.

    Forum entry #1: How to set music user token expiration?

    Question:

    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?

    Answer (from an Apple Media Engineer, 2 months ago):

    Thanks for your question regarding Media User Token expiration.

    The Media User Token expires after 6 months, currently. There is no way to configure this by the developer.

    Forum entry #2: When does a Music User token expire?

    Question:

    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.

    Answer (from a user, 1 year ago):

    The expiration is 6 months currently