Hello!
I'm working to integrate my web application with MusicKit JS. I am experiencing an issue with the authentication flow where the proper localStorage key is not set with the music token after authenticating successfully.
The expected output after going through the authentication flow is a localStorage key to be set with a name similar to "music.r4p2h4kf4l.u". I have tested my developer token using a simple HTML file, and after successfully authenticating, the localStorage key is set successfully. My web application that I am developing and experiencing this issue on is built using strapi/reactjs.
I have dug into this issue much deeper in the vendor JS code and have possibly narrowed the issue down to immediately after inputting the 6 digit security code. When testing using my simple JS file, a sessionStorage key named "ac" is set to my app's URL (in this example, localhost:3000). When I test using my strapi/react application, this sessionStorage key is not set, and thus I believe this is preventing calls to postMessage and localStorage to not function properly.
I have confirmed that when initially opening the auth dialog, the /woa endpoint is called and the referrer parameter is properly set.
Does anyone have any idea why this wouldn't work for a reactjs/strapi app? My actual authentication is succeeding and I see a music user token being successfully retrieved in the console within the auth popup.
I have spent a lot of time on this and am running out of ideas!
Post
Replies
Boosts
Views
Activity
Hello!
I am having trouble setting start times for songs when using the ApplicationMusicPlayer.
When I initialize a new MusicPlayer.Queue.Entry using the following constructor, I am seeing strange results:
init(
_ playableMusicItem: PlayableMusicItem,
startTime: TimeInterval? = nil,
endTime: TimeInterval? = nil
)
It appears that any value I provide for startTime is also applied to the endTime. For example:
MusicPlayer.Queue.Entry(playable, startTime: TimeInterval(30), endTime: TimeInterval(183))
provides the following console output:
MusicPlayer.Queue.Entry(id: "3D6A3DA3-595E-4657-8DBA-DDD245BBB7EF", transientItem: PlayableMusicItem, startTime: 30.0, endTime: 30.0)
I have also tried setting the endTime to nil with the same result. Does anyone have any experience setting start times for songs using the MusicKit ApplicationMusicPlayer?
Any feedback is greatly appreciated!
Hello!
I am currently working on a react.js application that is integrating with the MusicKit v3 library. I have followed the documentation to generate a JWT for MusicKit and add the library to my application.
Using my token I am able to successfully retrieve song information from the Apple Music API, but I am having trouble with authentication.
When I call music.authorize() and successfully go through the Apple sign in popup, I am receiving the following 403 error:
https://play.itunes.apple.com/WebObjects/MZPlay.woa/wa/webPlayerLogout 403 musickit.js:44 Uncaught (in promise) AUTHORIZATION_ERROR: Unauthorized
After stepping through the music kit API and login popup with breakpoints, I am seeing that the music user token is null, despite the login popup succeeding and returning a proper token/response:
{"isAppleMusicSubscriber":"true","musicUserToken":"Ak4ItOgRRRG2y6xgA/OeWQPK0RqPQ/esAJkRN0B/Ua/AWLT52tLhd2TfzMK6uhH+Nczvd7wjYDM1UewG/NledKtimwlrR+s5tdQPk/FG28zqhBqXZ12q6LC516w8ELZDwv5T61kV8xiJ1KSO1q4pGi01JO7SuPMtOqB/QsycYj+xNnrYUEwlP5tm/zxfg7bWmvuWMwfUruYR+A1U9FdXZsdIITVmxCjiHg8ro9xXRzl6Txhsag\u003d\u003d","cid":"REDACTED","itre":"REDACTED","supported":"REDACTED"}
I have tested my application with multiple Apple Music users who have paid subscriptions. All accounts are receiving this same error.
I have tried regenerating my JWT token multiple times following various guides. My latest attempt used the following node library and parameters:
var jwt = require('jsonwebtoken');
var fs = require('fs');
var privateKey = fs.readFileSync('./AuthKey_MYKEY.p8');
let now = new Date();
let nextMonth = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate());
let nowEpoch = Math.round(now.getTime() / 1000); // number of seconds since Epoch, in UTC
let nextMonthEpoch = Math.round(nextMonth.getTime() / 1000); // number of seconds since Epoch, in UTC
var payload = {
iss: 'REDACTED', // TEAM ID
iat: nowEpoch,
exp: nextMonthEpoch
};
var options = {
algorithm: 'ES256',
header: {
alg: 'ES256',
kid: 'REDACTED' // KEY ID
}
};
jwt.sign(payload, privateKey, options, function(error, token) {
console.log(error);
console.log(token);
});
I have a valid App Identifier created with the MusicKit App Service enabled.
I am stuck! I have no other ideas on the possible root cause here. Is there something I am missing? I have a mobile app currently in Test Flight - does this app need to be released to the app store? I am out of guesses!
Any support here would be greatly appreciated!
Thank you for your time.
Patrick