[Apple Music API] How can i control Music User Token expiration time?

Hello there! I have a problem: when i create Music User Token via AppleMusicKit, it returns me token that expires after one or two days. But regarding to this threads - https://developer.apple.com/forums/thread/654814 https://developer.apple.com/forums/thread/685343 it should expire in 6 months!

Do I need to consider something when creating a token so that its lifetime will be 6 months and not 2 days? Maybe something with developer token or with MusicKit? Maybe something in apple account?

p.s. i tried to find solution of this problem in internet and noticed that many other people have such problem too. And no one got any answers expect that token should live 6 months.

Regarding the developer token:

• You create this token, and you can set its expiration up to 6 months from the creation date. The expiration can be sooner if you wish..

Regarding the user token:

• This is created by the device (iPhone, etc) on behalf of the current user, and doesn't depend on your app for its creation. You don't really care when it expires, because the device is also responsible for creating a new user token when the current one is no longer valid.

What are you doing with the user token that tells you it's expired? If you're using the MusicKit framework, the user token should be handled automatically with MusicAuthorization.request().

If you're using the REST API, you can get a valid user token via https://developer.apple.com/documentation/storekit/skcloudservicecontroller/2909079-requestusertoken, which (again, only if your app is using the REST API) it should do every time it launches, assuming it needs to make user-specific requests.

@Polyphonic thank you for your answer!

But i have another case. I'm developing app which main feature is to show you what your friends have listened recently. I'm using MusicKit to get MusicUserToken, then i save this token to my backend and then use it to update information about user's last listened tracks (using this method - https://developer.apple.com/documentation/applemusicapi/get_recently_played_tracks of AppleMusicApi). The idea is that a user can login once and then not login to the app every day. But now I'm using the method above on backend and 1-2 days after the MusicUserToken is created, it starts returning 403.

So is there any way to update MusicUserToken on backend or, initially, get a token that will live a long time (6 month will be great :) )?

Hello, same use case here!

Someone knows if there is a workaround or if it's just not feasible?

Thanks in advance for your responses

Same here, any update? Cheers

[Apple Music API] How can i control Music User Token expiration time?
 
 
Q