Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Apple Music): Automated Authentication #623

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

Khadeeejah
Copy link
Contributor

Since freyr doesn't use custom-generated Apple Music tokens, and instead opts for the one embedded in the music.apple.com website, these tokens typically have a validity period of 3 months or under.

Making it so we have to update these tokens rather frequently, which is not ideal for persistence.

#590 highlights a pattern for extracting the token from the website, and this patch automates that, merging it right into freyr's authentication logic.

Now, we no longer need a developerToken in conf.json as it would be fetched from the Apple Music website on the first-run.

And any subsequent token updates when expired will be updated with the same process.

Making sure, we never have any periods of unauthentication past this point.

@miraclx miraclx linked an issue Jan 2, 2024 that may be closed by this pull request
@@ -53,8 +53,7 @@
"refreshToken": "AQCbeNs5NiGfHa6He0BlOdoQwEIdo2lwBmefEvpvqVy8WlL2HV7rmGbb30_oaZHMDf9MgXtGjI0gV_QukL33PE8c2bGqJHeMqdHBUjKWhxOW19snJkGUiyxen8UvmDG-OP4"
},
"apple_music": {
"storefront": "us",
"developerToken": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNzAyNTAyMjM0LCJleHAiOjE3MDk3NTk4MzQsInJvb3RfaHR0cHNfb3JpZ2luIjpbImFwcGxlLmNvbSJdfQ.zzeMLmez71PLinP9GozYSQnF7NYyCiXHB9tKL3-cyu3LzyeRnYz0ejLj4CrNJs0dlNkFg9_mwKmMLueUAR-KRg"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially love this~!

instance.axiosInstance.interceptors.request.use(conf => ((conf.headers.origin = 'https://music.apple.com'), conf));
this.#store.core = new Client({});
this.#store.axiosInstance = this.#store.core.songs.axiosInstance;
for (let instance of [this.#store.core.albums, this.#store.core.artists, this.#store.core.playlists])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

@miraclx miraclx merged commit 9222826 into miraclx:master Jan 2, 2024
17 of 18 checks passed
@miraclx miraclx mentioned this pull request Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automate Apple Music token updates
2 participants