Do Apple Music User Tokens expire?

1.2k views Asked by At

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!

2

There are 2 answers

0
B. Fleming On BEST ANSWER

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

8
adilanchian On

I've been trying to figure this out as well. I just made a call to create a playlist on behalf of a user and received a 403. Unfortunately, I don't know how long the token has been sitting stale, but I do think it has been close to 1 - 2 months...

The other issue here is you have to re-prompt the user to sign in (as I don't think there is a refresh token endpoint). Maybe we can find a solution together on this!